Class: Puppet::ResourceApi::TypeDefinition
- Inherits:
-
Object
- Object
- Puppet::ResourceApi::TypeDefinition
- Defined in:
- lib/puppet/resource_api/type_definition.rb
Overview
Provides accessor methods for the type being provided
Instance Attribute Summary collapse
-
#definition ⇒ Object
readonly
Returns the value of attribute definition.
Instance Method Summary collapse
- #attributes ⇒ Object
- #ensurable? ⇒ Boolean
-
#feature?(feature) ⇒ Boolean
rubocop complains when this is named has_feature?.
-
#initialize(definition) ⇒ TypeDefinition
constructor
A new instance of TypeDefinition.
- #namevars ⇒ Object
Constructor Details
#initialize(definition) ⇒ TypeDefinition
Returns a new instance of TypeDefinition.
5 6 7 8 |
# File 'lib/puppet/resource_api/type_definition.rb', line 5 def initialize(definition) raise Puppet::DevError, 'TypeDefinition requires definition to be a Hash' unless definition.is_a?(Hash) @definition = definition end |
Instance Attribute Details
#definition ⇒ Object (readonly)
Returns the value of attribute definition.
3 4 5 |
# File 'lib/puppet/resource_api/type_definition.rb', line 3 def definition @definition end |
Instance Method Details
#attributes ⇒ Object
10 11 12 |
# File 'lib/puppet/resource_api/type_definition.rb', line 10 def attributes @definition[:attributes] end |
#ensurable? ⇒ Boolean
14 15 16 |
# File 'lib/puppet/resource_api/type_definition.rb', line 14 def ensurable? @definition[:attributes].key?(:ensure) end |
#feature?(feature) ⇒ Boolean
rubocop complains when this is named has_feature?
25 26 27 28 29 30 31 32 33 |
# File 'lib/puppet/resource_api/type_definition.rb', line 25 def feature?(feature) supported = (definition[:features] && definition[:features].include?(feature)) if supported Puppet.debug("#{definition[:name]} supports `#{feature}`") else Puppet.debug("#{definition[:name]} does not support `#{feature}`") end supported end |
#namevars ⇒ Object
18 19 20 21 22 |
# File 'lib/puppet/resource_api/type_definition.rb', line 18 def namevars @namevars ||= @definition[:attributes].select { |_name, | .key?(:behaviour) && [:behaviour] == :namevar }.keys end |