<Derek.Whayman@barclayscapital.com>
2007-Aug-20 09:48 UTC
Common routines for custom functions
Hello I want to share some common subroutines between my custom functions. Given the way Puppet loads the .rb files in $plugindest/puppet/parser/functions, does anyone know how should I lay this out? I tried creating a module myutilities def self.blah() ... end end (NOT within the newfunction() call) in one of the (top-level) functions'' .rb file. However, calling myutilities::blah() doesn''t always work - it seems only to be work when you *first* call the specific function whose .rb file I''ve bundled the subroutine in. Maybe a loading issue? Is there an easy way to do this? Many thanks, Derek ------------------------------------------------------------------------ For important statutory and regulatory disclosures and more information about Barclays Capital, please visit our web site at http://www.barcap.com. Internet communications are not secure and therefore the Barclays Group does not accept legal responsibility for the contents of this message. Although the Barclays Group operates anti-virus programmes, it does not accept responsibility for any damage whatsoever that is caused by viruses being passed. Any views or opinions presented are solely those of the author and do not necessarily represent those of the Barclays Group. Replies to this email may be monitored by the Barclays Group for operational or business reasons. Barclays Capital is the investment banking division of Barclays Bank PLC, a company registered in England (number 1026167) with its registered office at 1 Churchill Place, London, E14 5HP. This email may relate to or be sent from other members of the Barclays Group. ------------------------------------------------------------------------
On Aug 20, 2007, at 4:48 AM, <Derek.Whayman@barclayscapital.com> <Derek.Whayman@barclayscapital.com> wrote:> However, calling myutilities::blah() doesn''t always work - it seems > only > to be work when you *first* call the specific function whose .rb file > I''ve bundled the subroutine in. Maybe a loading issue?Strange. I''d recommend adding something like this to the file your function is in: require ''path/to/your/module'' class Puppet::Parser::Scope include YourModule end The functions actually get added as methods in the Scope class, so this should do what you want. -- The only difference between the Democrats and the Republicans is that the Democrats allow the poor to be corrupt, too. -- Oscar Levant --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com