Class: RolesManagementAPI::Role

Inherits:
Object
  • Object
show all
Defined in:
lib/roles-management-api/role.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(role_id, json) ⇒ Role

Creates a new Role object from a NET/HTTP response (see client.rb)



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/roles-management-api/role.rb', line 6

def initialize(role_id, json)
  @id = role_id
  @application_id = json[:application_id]
  @description = json[:description]
  @name = json[:name]
  @token = json[:token]

  @assignments = RoleAssignmentArray.new(role_id)
  json[:role_assignments_attributes].each do |assignment_json|
    @assignments << RoleAssignment.new(assignment_json)
  end

  @members = []
  json[:members].each do |member|
    @members << Person.new(member)
  end
end

Instance Attribute Details

#application_idObject

Returns the value of attribute application_id.



3
4
5
# File 'lib/roles-management-api/role.rb', line 3

def application_id
  @application_id
end

#assignmentsObject

Returns the value of attribute assignments.



3
4
5
# File 'lib/roles-management-api/role.rb', line 3

def assignments
  @assignments
end

#descriptionObject

Returns the value of attribute description.



3
4
5
# File 'lib/roles-management-api/role.rb', line 3

def description
  @description
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/roles-management-api/role.rb', line 3

def id
  @id
end

#membersObject

Returns the value of attribute members.



3
4
5
# File 'lib/roles-management-api/role.rb', line 3

def members
  @members
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/roles-management-api/role.rb', line 3

def name
  @name
end

#tokenObject

Returns the value of attribute token.



3
4
5
# File 'lib/roles-management-api/role.rb', line 3

def token
  @token
end

Instance Method Details

#as_jsonObject



24
25
26
27
28
29
30
# File 'lib/roles-management-api/role.rb', line 24

def as_json
  {
    role: {
      role_assignments_attributes: @assignments.as_json
    }
  }
end