Class: Conjur::DSL2::Types::Base
- Extended by:
- AttributeDefinition, InheritableAttribute, TypeChecking
- Defined in:
- lib/conjur/dsl2/types/base.rb
Overview
Base class for implementing structured DSL object types such as Role, User, etc.
To define a type:
-
Inherit from this class
-
Define attributes using
attribute
Your new type will automatically be registered with the YAML parser with a tag corresponding to the lower-cased short name of the class.
Direct Known Subclasses
Ruby::Policy, Create, Deny, Give, Grant, ManagedRole, Member, Permit, Record, Retire, Revoke, Update
Class Method Summary collapse
-
.inherited(cls) ⇒ Object
Hook to register the YAML type.
- .register_yaml_type(simple_name) ⇒ Object
-
.short_name ⇒ Object
(also: simple_name)
The last token in the ::-separated class name.
Instance Method Summary collapse
- #custom_attribute_names ⇒ Object
- #id_attribute ⇒ Object
-
#referenced_records ⇒ Object
Gets all ‘child’ records.
- #resource? ⇒ Boolean
-
#role? ⇒ Boolean
Things aren’t roles by default.
Methods included from InheritableAttribute
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
Class Method Details
.inherited(cls) ⇒ Object
Hook to register the YAML type.
316 317 318 |
# File 'lib/conjur/dsl2/types/base.rb', line 316 def inherited cls cls.register_yaml_type cls.short_name.underscore.gsub('_', '-') end |
.register_yaml_type(simple_name) ⇒ Object
327 328 329 |
# File 'lib/conjur/dsl2/types/base.rb', line 327 def register_yaml_type simple_name ::YAML.add_tag "!#{simple_name}", self end |
.short_name ⇒ Object Also known as: simple_name
The last token in the ::-separated class name.
321 322 323 |
# File 'lib/conjur/dsl2/types/base.rb', line 321 def short_name self.name.demodulize end |
Instance Method Details
#custom_attribute_names ⇒ Object
290 291 292 |
# File 'lib/conjur/dsl2/types/base.rb', line 290 def custom_attribute_names [ ] end |
#id_attribute ⇒ Object
288 |
# File 'lib/conjur/dsl2/types/base.rb', line 288 def id_attribute; 'id'; end |
#referenced_records ⇒ Object
Gets all ‘child’ records.
303 304 305 306 307 308 309 310 311 312 |
# File 'lib/conjur/dsl2/types/base.rb', line 303 def referenced_records result = [] instance_variables.map do |var| value = instance_variable_get var Array(value).each do |val| result.push val if val.is_a?(Conjur::DSL2::Types::Base) end end result.flatten end |
#resource? ⇒ Boolean
294 295 296 |
# File 'lib/conjur/dsl2/types/base.rb', line 294 def resource? false end |
#role? ⇒ Boolean
Things aren’t roles by default
284 285 286 |
# File 'lib/conjur/dsl2/types/base.rb', line 284 def role? false end |