Class: Conjur::Policy::Types::ManagedRole
- Includes:
- ActsAsRole
- Defined in:
- lib/conjur/policy/types/records.rb
Class Method Summary collapse
Instance Method Summary collapse
- #account ⇒ Object
- #id ⇒ Object
-
#initialize(record = nil, role_name = nil) ⇒ ManagedRole
constructor
A new instance of ManagedRole.
- #role_kind ⇒ Object
- #to_s ⇒ Object
Methods included from ActsAsRole
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
Constructor Details
#initialize(record = nil, role_name = nil) ⇒ ManagedRole
Returns a new instance of ManagedRole.
431 432 433 434 |
# File 'lib/conjur/policy/types/records.rb', line 431 def initialize record = nil, role_name = nil self.record = record if record self.role_name = role_name if role_name end |
Class Method Details
.build(fullid) ⇒ Object
477 478 479 480 481 482 483 484 485 486 487 488 |
# File 'lib/conjur/policy/types/records.rb', line 477 def build fullid account, kind, id = fullid.split(':', 3) raise "Expecting @ for kind, got #{kind}" unless kind == "@" id_tokens = id.split('/') record_kind = id_tokens.shift role_name = id_tokens.pop record = Conjur::Policy::Types.const_get(record_kind.classify).new.tap do |record| record.id = id_tokens.join('/') record.account = account end self.new record, role_name end |
Instance Method Details
#account ⇒ Object
496 497 498 |
# File 'lib/conjur/policy/types/records.rb', line 496 def account record.account end |
#id ⇒ Object
504 505 506 |
# File 'lib/conjur/policy/types/records.rb', line 504 def id [ record.role_kind, record.id, role_name ].join('/') end |
#role_kind ⇒ Object
500 501 502 |
# File 'lib/conjur/policy/types/records.rb', line 500 def role_kind "@" end |
#to_s ⇒ Object
491 492 493 494 |
# File 'lib/conjur/policy/types/records.rb', line 491 def to_s role_name = self.id.split('/')[-1] "'#{role_name}' on #{record}" end |