Method: Puppet::Provider::AixObject.mapping
- Defined in:
- lib/puppet/provider/aix_object.rb
.mapping(info = {}) ⇒ Object
Add a mapping from a Puppet property to an AIX attribute. The info must include:
* :puppet_property -- The puppet property corresponding to this attribute
* :aix_attribute -- The AIX attribute corresponding to this attribute. Defaults
to puppet_property if this is not provided.
* :property_to_attribute -- A lambda that converts a Puppet Property to an AIX attribute
value. Defaults to the identity function if not provided.
* :attribute_to_property -- A lambda that converts an AIX attribute to a Puppet property.
Defaults to the identity function if not provided.
NOTE: The lambdas for :property_to_attribute or :attribute_to_property can be ‘pure’ or ‘impure’. A ‘pure’ lambda is one that needs only the value to do the conversion, while an ‘impure’ lambda is one that requires the provider instance along with the value. ‘Pure’ lambdas have the interface ‘do |value| …’ while ‘impure’ lambdas have the interface ‘do |provider, value| …’.
NOTE: ‘Impure’ lambdas are useful in case we need to generate more specific error messages or pass-in instance-specific command-line arguments.
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/puppet/provider/aix_object.rb', line 97 def mapping(info = {}) identity_fn = ->(x) { x } info[:aix_attribute] ||= info[:puppet_property] info[:property_to_attribute] ||= identity_fn info[:attribute_to_property] ||= identity_fn mappings[:aix_attribute][info[:puppet_property]] = MappedObject.new( info[:aix_attribute], :convert_property_value, info[:property_to_attribute] ) mappings[:puppet_property][info[:aix_attribute]] = MappedObject.new( info[:puppet_property], :convert_attribute_value, info[:attribute_to_property] ) end |