On Sun, May 22, 2011 at 05:56:29PM -0700, Dan Bode wrote: > I just finished something very similar: > > > def self.title_join(hash) > "#{hash[:domain]}/#{hash[:type]}/#{hash[:item]}" > end > > where the default case was: > > + def self.title_join(hash) > + case key_attributes.length > + when 0,1; hash[:name] > + else > + Puppet.warning('you should specify a joiner when there are two of > more key a > + end > + end > Hm, does this work in case I have one keyattribute that is not "name" (like the fileresource where the keyattribute is "path")?
If not, here is a second suggestion def self.title_join(hash) # extract all parameters that are keyattributes to build defaulttitle passed_keyattributes = hash.values_at(*self.key_attributes) if passed_keyattributes.include?(nil) nil # or raise an error? else passed_keyattributes.join('/') end end This way you only have to overwrite the method if you're unhappy with the default joiner "/". -Stefan
pgpCr3W31OydW.pgp
Description: PGP signature