On Mon, Dec 1, 2014 at 9:06 PM, Geoffrey Gardella <[email protected]>
wrote:

> I am working on updating types/providers for new functionality in Solaris.
> I need to take a list of properties (not their values) and modify them
> before any operations (checking current values, etc). Specifically, I will
> need to substitute '-' for '_' in the property names. What is the proper
> place for me to do this? In the provider or type? I am very new to Puppet,
> and don't want to implement a solution that isn't done the right way.
>
> I know I'm being a bit vague, but this is in response to functional
> changes in Solaris, which aren't even integrated yet.
>

Assuming this is a static list of properties, then you would define the
list of properties in the type, e.g. newproperty(:property_one), and then
define getter and setters in the provider:

def property_one
  # retrieve the value
end

def property_one=(value)
  # set the new value
end

That assumes each property can be independently managed. If you need both
property_one and property_two to be set before you apply the changes to the
underlying native resource, then you'd want the setters to store the new
values:

def property_one=(value)
  @one = value
end

def property_two=(value)
  @two = value
end

and implement a `flush` method to update the resource with all of the new
values.

def flush
  # save resource using @one & @two
end

Josh

-- 
Josh Cooper
Developer, Puppet Labs

*Join us at **PuppetConf 2015, October 5-9 in Portland, OR - *
http://2015.puppetconf.com.
*Register early to save 40%!*

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-dev/CA%2Bu97unYZfK5xpG3REVhq_nzP7PMGxj%3DN%2BgBdc0bjcOu7kechw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to