Class: Vedeu::Group
Overview
Interfaces can be associated with one another by being members of the same Group. A Group is a collection of interface names.
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Attributes included from Model
Instance Method Summary collapse
-
#add(member) ⇒ Group
Add a member to the group by name.
- #defaults ⇒ Hash private
-
#initialize(attributes = {}) ⇒ Group
constructor
Return a new instance of Group.
-
#members ⇒ Set
Return the members as a Set.
-
#remove(member) ⇒ Group
Remove a member from the group by name.
-
#reset ⇒ Group
Remove all members from the group.
Methods included from Model
#demodulize, #deputy, #dsl_class, included, #store
Constructor Details
#initialize(attributes = {}) ⇒ Group
Return a new instance of Group.
21 22 23 24 25 26 27 |
# File 'lib/vedeu/models/group.rb', line 21 def initialize(attributes = {}) @attributes = defaults.merge!(attributes) @members = Array(@attributes[:members]) @name = @attributes[:name] @repository = @attributes[:repository] end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
10 11 12 |
# File 'lib/vedeu/models/group.rb', line 10 def name @name end |
Instance Method Details
#add(member) ⇒ Group
Add a member to the group by name.
33 34 35 36 37 |
# File 'lib/vedeu/models/group.rb', line 33 def add(member) @members = members.add(member) Group.new({ name: name, members: @members }).store end |
#defaults ⇒ Hash (private)
66 67 68 69 70 71 72 |
# File 'lib/vedeu/models/group.rb', line 66 def defaults { members: [], name: '', repository: Vedeu.groups, } end |
#members ⇒ Set
Return the members as a Set.
42 43 44 |
# File 'lib/vedeu/models/group.rb', line 42 def members @members.to_set end |