Class: Code42::RoleCollection
- Inherits:
-
Object
- Object
- Code42::RoleCollection
- Includes:
- Enumerable
- Defined in:
- lib/code42/role_collection.rb
Instance Method Summary collapse
- #attributes ⇒ Object
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
- #includes_id?(id) ⇒ Boolean
- #includes_name?(name) ⇒ Boolean
-
#initialize(roles = []) ⇒ RoleCollection
constructor
A new instance of RoleCollection.
- #serialize ⇒ Object
Constructor Details
#initialize(roles = []) ⇒ RoleCollection
Returns a new instance of RoleCollection.
5 6 7 |
# File 'lib/code42/role_collection.rb', line 5 def initialize(roles = []) @roles = roles end |
Instance Method Details
#attributes ⇒ Object
19 20 21 |
# File 'lib/code42/role_collection.rb', line 19 def attributes map(&:attributes) end |
#each(&block) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/code42/role_collection.rb', line 9 def each(&block) @roles.each do |role| if block_given? block.call role else yield role end end end |
#empty? ⇒ Boolean
35 36 37 |
# File 'lib/code42/role_collection.rb', line 35 def empty? @roles.empty? end |
#includes_id?(id) ⇒ Boolean
27 28 29 |
# File 'lib/code42/role_collection.rb', line 27 def includes_id?(id) map(&:id).include? id end |
#includes_name?(name) ⇒ Boolean
31 32 33 |
# File 'lib/code42/role_collection.rb', line 31 def includes_name?(name) map(&:name).include? name end |
#serialize ⇒ Object
23 24 25 |
# File 'lib/code42/role_collection.rb', line 23 def serialize map(&:serialize) end |