Class: Conjur::RoleGrant

Inherits:
Object
  • Object
show all
Extended by:
BuildObject::ClassMethods, Cast
Defined in:
lib/conjur/role_grant.rb

Overview

Represents the membership of a role. RoleGrants are returned by ActsAsRole#members and represent members of the role on which the method was invoked.

Examples:

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from BuildObject::ClassMethods

build_object

Instance Attribute Details

#admin_optionBoolean (readonly)

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

Returns:

  • (Boolean)


44
45
46
# File 'lib/conjur/role_grant.rb', line 44

def admin_option
  @admin_option
end

#memberConjur::Role (readonly)

The member role in the relationship

Returns:



39
40
41
# File 'lib/conjur/role_grant.rb', line 39

def member
  @member
end

#roleConjur::Role (readonly)

The role which was granted.

Returns:



35
36
37
# File 'lib/conjur/role_grant.rb', line 35

def role
  @role
end

Instance Method Details

#as_json(options = {}) ⇒ Object



71
72
73
# File 'lib/conjur/role_grant.rb', line 71

def as_json options = {}
  to_h.as_json(options)
end

#to_hObject

Representation of the role grant as a hash.



59
60
61
62
63
64
65
# File 'lib/conjur/role_grant.rb', line 59

def to_h
  {
    role: role.id,
    member: member.id,
    admin_option: admin_option
  }
end

#to_sObject



67
68
69
# File 'lib/conjur/role_grant.rb', line 67

def to_s
  to_h.to_s
end