Class: Conjur::Policy::Types::AutomaticRole
- 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) ⇒ AutomaticRole
constructor
A new instance of AutomaticRole.
- #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) ⇒ AutomaticRole
Returns a new instance of AutomaticRole.
436 437 438 439 |
# File 'lib/conjur/policy/types/records.rb', line 436 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
485 486 487 488 489 490 491 492 493 494 495 496 |
# File 'lib/conjur/policy/types/records.rb', line 485 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
504 505 506 |
# File 'lib/conjur/policy/types/records.rb', line 504 def account record.account end |
#id ⇒ Object
512 513 514 |
# File 'lib/conjur/policy/types/records.rb', line 512 def id [ record.role_kind, record.id, role_name ].join('/') end |
#role_kind ⇒ Object
508 509 510 |
# File 'lib/conjur/policy/types/records.rb', line 508 def role_kind "@" end |
#to_s ⇒ Object
499 500 501 502 |
# File 'lib/conjur/policy/types/records.rb', line 499 def to_s role_name = self.id.split('/')[-1] "'#{role_name}' on #{record}" end |