Class: Code42::RoleCollection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/code42/role_collection.rb

Instance Method Summary collapse

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

#attributesObject



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

Returns:

  • (Boolean)


35
36
37
# File 'lib/code42/role_collection.rb', line 35

def empty?
  @roles.empty?
end

#includes_id?(id) ⇒ Boolean

Returns:

  • (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

Returns:

  • (Boolean)


31
32
33
# File 'lib/code42/role_collection.rb', line 31

def includes_name?(name)
  map(&:name).include? name
end

#serializeObject



23
24
25
# File 'lib/code42/role_collection.rb', line 23

def serialize
  map(&:serialize)
end