Class: MOCO::Unit
- Inherits:
-
BaseEntity
- Object
- BaseEntity
- MOCO::Unit
- Defined in:
- lib/moco/entities/unit.rb
Overview
Represents a MOCO unit/team (Teams)
Required attributes for create:
name - String, team name (e.g., "Development Team")
Read-only attributes:
id, users (Array of user hashes), created_at, updated_at
Example:
# Create a new team
moco.units.create(name: "Marketing Team")
# Get users in a team
team = moco.units.find(123)
team.users # => Array of User objects
Note:
To assign users to a team, update the user with unit_id:
moco.users.update(user_id, unit_id: team.id)
Deleting a unit is only possible if no users are assigned to it.
Instance Attribute Summary
Attributes inherited from BaseEntity
Instance Method Summary collapse
- #to_s ⇒ Object
-
#users ⇒ Object
Get users belonging to this unit.
Methods inherited from BaseEntity
#==, #association, #destroy, #eql?, #has_many, #hash, #id, #initialize, #inspect, #reload, #save, #to_h, #to_json, #update
Constructor Details
This class inherits a constructor from MOCO::BaseEntity
Instance Method Details
#to_s ⇒ Object
32 33 34 |
# File 'lib/moco/entities/unit.rb', line 32 def to_s name.to_s end |
#users ⇒ Object
Get users belonging to this unit
28 29 30 |
# File 'lib/moco/entities/unit.rb', line 28 def users has_many(:users, :unit_id) end |