class Conjur::Policy::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/policy/types/base.rb, line 347 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/policy/types/base.rb, line 358 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/policy/types/base.rb, line 352 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/policy/types/base.rb, line 321 def custom_attribute_names [ ] end
id_attribute()
click to toggle source
# File lib/conjur/policy/types/base.rb, line 319 def id_attribute; 'id'; end
referenced_records()
click to toggle source
Gets all 'child' records.
# File lib/conjur/policy/types/base.rb, line 334 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::Policy::Types::Base) end end result.flatten end
resource?()
click to toggle source
# File lib/conjur/policy/types/base.rb, line 325 def resource? false end
role?()
click to toggle source
Things aren't roles by default
# File lib/conjur/policy/types/base.rb, line 315 def role? false end