Class: Conjur::Policy::Types::Grant

Inherits:
Base show all
Includes:
AutomaticRoleDSL, RoleMemberDSL
Defined in:
lib/conjur/policy/types/grant.rb

Instance Method Summary collapse

Methods included from AutomaticRoleDSL

#automatic_role

Methods included from RoleMemberDSL

included

Methods inherited from Base

#custom_attribute_names, #id_attribute, inherited, #referenced_records, register_yaml_type, #resource?, #role?, short_name

Methods included from InheritableAttribute

inherit_for, #inheritable_attr

Methods included from TypeChecking

#expect_array, #expect_boolean, #expect_hash, #expect_integer, #expect_layer, #expect_member, #expect_permission, #expect_record, #expect_resource, #expect_role, #expect_string, #expect_type, #test_resource, #test_role

Methods included from AttributeDefinition

#attribute, #define_field, #define_plural_field, #field?, #yaml_field?, #yaml_field_type

Instance Method Details

#to_sObject



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/conjur/policy/types/grant.rb', line 50

def to_s
  role_str   = if role.kind_of?(Array)
    role.join(', ')
  else
    role
  end
  member_str = if member.kind_of?(Array)
    member.map(&:role).join(', ')
  elsif member 
    member.role
  end
  admin = Array(member).map do |member|
    member && member.admin
  end
  admin_str = if Array(member).count == admin.select{|admin| admin}.count
    " with admin option"
  elsif admin.any?
    " with admin options: #{admin.join(', ')}"
  end
  %Q(Grant #{role_str} to #{member_str}#{replace ? ' with replacement ' : ''}#{admin_str})
end