class Conjur::DSL2::Types::Base
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.
Public Class Methods
inherited(cls)
click to toggle source
Hook to register the YAML
type.
# 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)
click to toggle source
# File lib/conjur/dsl2/types/base.rb, line 327 def register_yaml_type simple_name ::YAML.add_tag "!#{simple_name}", self end
short_name()
click to toggle source
The last token in the ::-separated class name.
# File lib/conjur/dsl2/types/base.rb, line 321 def short_name self.name.demodulize end
Also aliased as: simple_name
Public Instance Methods
custom_attribute_names()
click to toggle source
# File lib/conjur/dsl2/types/base.rb, line 290 def custom_attribute_names [ ] end
id_attribute()
click to toggle source
# File lib/conjur/dsl2/types/base.rb, line 288 def id_attribute; 'id'; end
referenced_records()
click to toggle source
Gets all ‘child’ records.
# 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?()
click to toggle source
# File lib/conjur/dsl2/types/base.rb, line 294 def resource? false end
role?()
click to toggle source
Things aren’t roles by default
# File lib/conjur/dsl2/types/base.rb, line 284 def role? false end