Thanks Stefan,

I toyed around with that idea a bit but, at this point, the code is SO
much clearer/cleaner in the 'initialize' define that I think it will
become my preferred method of doing this type of thing and I couldn't
quite get it to work with what I wanted to do since I really just
want:

some_type { 'meaningless_name':
   foo => 'stuff',
   bar => 'other stuff',
   baz => 'more stuff'
}

BUT, bar needs to have a default value (doesn't appear to be supported
by title_patterns) and foo, bar, and baz, all have to be collectively
unique within the type declarations.

Thanks,

Trevor

On Mon, Sep 10, 2012 at 11:57 AM, Stefan Schulte
<[email protected]> wrote:
> On Mon, Sep 10, 2012 at 10:07:14AM -0400, Trevor Vaughan wrote:
>> All,
>>
>> Is it possible to use default values in a composite namevar?
>>
>> I'm having a heck of a time making it work properly.
>>
>> I tried:
>>
>> def self.title_patterns
>>     [
>>       [
>>         /^(.*)$/,
>>        [
>>           [:path, lambda{|x| x }],
>>           [:function, lambda{|x| x }]
>>         ]
>>       ]
>>     ]
>>     end
>>
>
> You have to define two title_patterns. If you have one title pattern
> (that may set :path to nil and :function to "foo") it won't work.
>
> I once tried to write a /etc/service provider (#5660) and wanted to have
> the name (e.g. "domain") and protocol (e.g. "udp") to be namevars and to
> have tcp as the default protocol. I looked at my title pattern and
> noticed this comment:
>
>     def self.title_patterns
>       [
>         # we have two title_patterns "name" and "name:protocol". We won't use
>         # one pattern (that will eventually set :protocol to nil) because we
>         # want to use a default value for :protocol. And that does only work
>         # if :protocol is not put in the parameter hash while initialising
>         [
>           /^(.*?)\/(tcp|udp)$/, # Set name and protocol
>           [
>             # We don't need a lot of post-parsing
>             [ :name, lambda{|x| x} ],
>             [ :protocol, lambda{ |x| x.intern unless x.nil? } ]
>           ]
>         ],
>         [
>           /^(.*)$/,
>           [
>             [ :name, lambda{|x| x} ]
>           ]
>         ]
>       ]
>     end
>
> I hope this helps.
>
> -Stefan
>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Puppet Developers" group.
> 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.
>



-- 
Trevor Vaughan
Vice President, Onyx Point, Inc
(410) 541-6699
[email protected]

-- This account not approved for unencrypted proprietary information --

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
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