Class: Conjur::DSL2::Types::ManagedRole
- Includes:
- ActsAsRole
- Defined in:
- lib/conjur/dsl2/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, #yaml_field?, #yaml_field_type
Constructor Details
#initialize(record = nil, role_name = nil) ⇒ ManagedRole
Returns a new instance of ManagedRole.
213 214 215 216 |
# File 'lib/conjur/dsl2/types/records.rb', line 213 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
222 223 224 225 226 227 228 229 230 231 232 233 |
# File 'lib/conjur/dsl2/types/records.rb', line 222 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::DSL2::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
241 242 243 |
# File 'lib/conjur/dsl2/types/records.rb', line 241 def account record.account end |
#id ⇒ Object
249 250 251 |
# File 'lib/conjur/dsl2/types/records.rb', line 249 def id [ record.role_kind, record.id, role_name ].join('/') end |
#role_kind ⇒ Object
245 246 247 |
# File 'lib/conjur/dsl2/types/records.rb', line 245 def role_kind "@" end |
#to_s ⇒ Object
236 237 238 239 |
# File 'lib/conjur/dsl2/types/records.rb', line 236 def to_s role_name = self.id.split('/')[-1] "'#{role_name}' on #{record}" end |