Jakov Sosic
2014-Apr-16 17:15 UTC
[Puppet Users] Same methods in two providers - how to optimize it?
Hi, I'm developing some of my custom types, and some of them share same params, with exactly the same methods... For example, I have these params in three of my types and they are same: lib/puppet/type/mytype1.rb lib/puppet/type/mytype2.rb lib/puppet/type/mytype3.rb newproperty(:comment) do defaultto '' end Is there a way I can maybe extract that code into some external library and reuse it in all of my three types? Now, this definition is not a problem, but when you start to include various checks, and override methods like insync? and your param code grows to 30-40 lines, and you use it in multiple types, it gets usefull to extract that code to some external class and include it into these types. I have same problem with methods in providers, for example: lib/puppet/provider/mytype1/default.rb lib/puppet/provider/mytype2/default.rb lib/puppet/provider/mytype3/default.rb all have for example: # sets comment def comment=(value) @property_hash[:comment]=(value) end Is there a way to extract method provider into some external file and just include it somehow? If it's possible I would like to escape a route of creating another custom type, and add its value to param of another custom type :-/ -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/3ac5529c-9bfe-44a3-a150-ce6598e56bde%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.