class Conjur::RoleGrant

Represents the membership of a role. ‘RoleGrant`s are returned by {ActsAsRole#members} and represent members of the role on which the method was invoked.

@example

alice.members.map{|grant| grant.member}.include? admin_role # => true
admin_role.members.map{|grant| grant.member}.include? alice # => true

Attributes

admin_option[R]

When true, the role {#member} is allowed to give this grant to other roles

@return [Boolean]

member[R]

The member role in the relationship @return [Conjur::Role]

role[R]

The role which was granted. @return [Conjur::Role]

Public Class Methods

new(role, member, admin_option) click to toggle source

@api private

Create a new RoleGrant instance.

@param [Conjur::Role] member the member to which the role was granted @param [Boolean] admin_option whether ‘member` can give the grant to other roles

# File lib/conjur/role_grant.rb, line 47
def initialize role, member, admin_option
  @role = role
  @member = member
  @admin_option = admin_option
end
parse_from_json(json, credentials) click to toggle source

@api private

Create a ‘RoleGrant` from a JSON respnose

@param [Hash] json the parsed JSON response @param [Hash] credentials the credentials used to create APIs for the member and grantor role objects @return [Conjur::RoleGrant]

# File lib/conjur/role_grant.rb, line 78
def parse_from_json(json, credentials)
  role = build_object(json['role'], credentials, default_class: Role)
  member = build_object(json['member'], credentials, default_class: Role)
  RoleGrant.new(role, member, json['admin_option'])
end

Public Instance Methods

as_json(options = {}) click to toggle source
# File lib/conjur/role_grant.rb, line 66
def as_json options = {}
  to_h.as_json(options)
end
to_h() click to toggle source

Representation of the role grant as a hash.

# File lib/conjur/role_grant.rb, line 54
def to_h
  {
    role: role.id,
    member: member.id,
    admin_option: admin_option
  }
end
to_s() click to toggle source
# File lib/conjur/role_grant.rb, line 62
def to_s
  to_h.to_s
end