On Wednesday, May 9, 2012 2:00:01 PM UTC-7, Nick Lewis wrote:
>
> On Wednesday, May 9, 2012 at 1:55 PM, Philip Brown wrote:
>
> I'm interested in the pattern of
>
> if provider.respond_to?()
>
>
> In particular, 
>
> provider.validate if provider.respond_to?(:validate)
>
> I have 
>
> def validate
>   blah blah
>
> in my provider, but that does not seem to be enough.
>
> That *should* work. What respond_to? means is simply "does this object 
> have a public method by this name?" What's the behavior you're seeing? Is 
> it just not calling validate? And, importantly, are you certain it's not 
> calling validate?
>
> Beyond that, is the value of `provider` what you expect it to be? Do you 
> have multiple providers, and perhaps the wrong one is being used? Where 
> have you defined validate, and where are you calling it?
>

ookay.. lots of questions, so you get lots of answers :)


I need a top level validate, not one under a newparam(). I need to ensure 
that multiple params are defined, rather than just some of them.

I'm confirming/denying function calling, with big obnoxious lines such as
 Puppet.debug("   #### function called here")

1. if I define it in the "type" file, as
  validate do
    unless self[:fmri] and self[:property] and self[:value]
      raise ArgumentError,
            "svcprop must have fmri and property and value"
    end
  end

it works... BUT.. I want to allow multiple providers, and let them pick 
which arguments are required

2. If I have a  type-file definition. that invokes provider.validate, and 
then in the provider file, 

  def validate
     Puppet.debug(" #### Called")
  end


It gets called fine.
(What is the difference between "def validate", and "validate do", btw?! )



3. If I have no  type-file definition.  but just one in the provider file, 
similar to above,
it doesnt get called.


I've seen another type (file.rb), call

    provider.validate if provider.respond_to?(:validate)


but I dont see its providers doing anything beyond

"def validate
   ..."

So, I'm baffled.






 

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/puppet-dev/-/uJqNViZ_QZcJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to