Class: Puppet::ResourceApi::Property
- Inherits:
-
Property
- Object
- Property
- Puppet::ResourceApi::Property
- Defined in:
- lib/puppet/resource_api/property.rb
Overview
Class containing property functionality for ResourceApi.
Instance Method Summary collapse
-
#call_provider(_value) ⇒ Object
stop puppet from trying to call into the provider when no pre-defined values have been specified “This is not the provider you are looking for.” – Obi-Wan Kaniesobi.
-
#def_insync? ⇒ Boolean
method overloaded only for the :ensure property, add option to check if the rs_value matches is.
-
#initialize(type_name, data_type, attribute_name, resource_hash) ⇒ Property
constructor
This initialize takes arguments and sets up new property.
-
#rs_value ⇒ Object
used internally.
-
#should ⇒ type
This method returns value of the property.
-
#should=(value) ⇒ type
This method sets and returns value of the property and sets @shouldorig.
Constructor Details
#initialize(type_name, data_type, attribute_name, resource_hash) ⇒ Property
This initialize takes arguments and sets up new property. parent class.
14 15 16 17 18 19 20 21 22 |
# File 'lib/puppet/resource_api/property.rb', line 14 def initialize(type_name, data_type, attribute_name, resource_hash) @type_name = type_name @data_type = data_type @attribute_name = attribute_name # Define class method insync?(is) if the name is :ensure def_insync? if @attribute_name == :ensure && self.class != Puppet::ResourceApi::Property # Pass resource to parent Puppet class. super(resource_hash) end |
Instance Method Details
#call_provider(_value) ⇒ Object
stop puppet from trying to call into the provider when no pre-defined values have been specified “This is not the provider you are looking for.” – Obi-Wan Kaniesobi.
85 |
# File 'lib/puppet/resource_api/property.rb', line 85 def call_provider(_value); end |
#def_insync? ⇒ Boolean
method overloaded only for the :ensure property, add option to check if the rs_value matches is. Only if the class is child of Puppet::ResourceApi::Property.
72 73 74 |
# File 'lib/puppet/resource_api/property.rb', line 72 def def_insync? define_singleton_method(:insync?) { |is| rs_value.to_s == is.to_s } end |
#rs_value ⇒ Object
used internally
65 66 67 |
# File 'lib/puppet/resource_api/property.rb', line 65 def rs_value @should ? @should.first : @should end |
#should ⇒ type
This method returns value of the property.
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/puppet/resource_api/property.rb', line 26 def should if @attribute_name == :ensure && rs_value.is_a?(String) rs_value.to_sym elsif rs_value == false # work around https://tickets.puppetlabs.com/browse/PUP-2368 :false # rubocop:disable Lint/BooleanSymbol elsif rs_value == true # work around https://tickets.puppetlabs.com/browse/PUP-2368 :true # rubocop:disable Lint/BooleanSymbol else rs_value end end |
#should=(value) ⇒ type
This method sets and returns value of the property and sets @shouldorig.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/puppet/resource_api/property.rb', line 43 def should=(value) @shouldorig = value if @attribute_name == :ensure value = value.to_s end # Puppet requires the @should value to always be stored as an array. We do not use this # for anything else # @see Puppet::Property.should=(value) @should = [ Puppet::ResourceApi::DataTypeHandling.mungify( @data_type, value, "#{@type_name}.#{@attribute_name}", Puppet::ResourceApi.caller_is_resource_app?, ), ] end |