Hi. I have a small problem with the custom type I am working on. I define method ''evaluate'' which is called after all data is been collected. Here it is: module Puppet newtype(:test) do newparam(:name) do end newparam(:listen) do defaultto "silent" end def evaluate puts "evaluating..." return super.evaluate end end end The problem is that when running puppet I get: err: //default/testz/Test[1]: Failed to retrieve current state of resource: undefined method `evaluate'' for []:Array So, what does evaluate suppose to return? -- Dmitri Priimak
On Mon, Sep 24, 2007 at 02:36:36PM -0700, Dmitri Priimak wrote:> Hi. > > I have a small problem with the custom type I am working on. I define > method ''evaluate'' which is called after all data is been collected. Here > it is: > > module Puppet > newtype(:test) do > newparam(:name) do > end > > newparam(:listen) do > defaultto "silent" > end > > def evaluate > puts "evaluating..." > return super.evaluateI don''t think that does, what you think it does. Drop the .evaluate and things will probably be a lot happier. Give the "Inheritance and Messages" section of Chapter 3 of the Pickaxe another read.> So, what does evaluate suppose to return?The set of events that need executing, if I remember correctly. But I don''t use evaluate, preferring the more intuitive (to me, anyway) version described in wiki:PracticalTypes. - Matt -- Non-PHB basically told $MANAGER to go check his drive integrity. -- steve, ASR
Matthew Palmer wrote:> On Mon, Sep 24, 2007 at 02:36:36PM -0700, Dmitri Priimak wrote: > >> Hi. >> >> I have a small problem with the custom type I am working on. I define >> method ''evaluate'' which is called after all data is been collected. Here >> it is: >> >> module Puppet >> newtype(:test) do >> newparam(:name) do >> end >> >> newparam(:listen) do >> defaultto "silent" >> end >> >> def evaluate >> puts "evaluating..." >> return super.evaluate >> > > I don''t think that does, what you think it does. Drop the .evaluate and > things will probably be a lot happier. Give the "Inheritance and Messages" > section of Chapter 3 of the Pickaxe another read. >If I say def evaluate puts "evaluating..." end I get: err: Got an uncaught exception of type NoMethodError: undefined method `transaction='' for "is near":String>> So, what does evaluate suppose to return? >> > > The set of events that need executing, if I remember correctly. But I don''t > use evaluate, preferring the more intuitive (to me, anyway) version > described in wiki:PracticalTypes. >Pardon my ignorance but which part in wiki:PracticalTypes refer to it. -- Dmitri Priimak
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Tuesday 25 September 2007, Dmitri Priimak wrote:> Matthew Palmer wrote: > > On Mon, Sep 24, 2007 at 02:36:36PM -0700, Dmitri Priimak wrote: > >> Hi. > >> > >> I have a small problem with the custom type I am working on. I define > >> method ''evaluate'' which is called after all data is been collected. Here > >> it is: > >> > >> module Puppet > >> newtype(:test) do > >> newparam(:name) do > >> end > >> > >> newparam(:listen) do > >> defaultto "silent" > >> end > >> > >> def evaluate > >> puts "evaluating..." > >> return super.evaluate > > > > I don''t think that does, what you think it does. Drop the .evaluate and > > things will probably be a lot happier. Give the "Inheritance and > > Messages" section of Chapter 3 of the Pickaxe another read. > > If I say > def evaluate > puts "evaluating..." > end > > I get: > err: Got an uncaught exception of type NoMethodError: undefined > method `transaction='' for "is near":StringI think Matthew really referred only to the ".evaluate" string, giving: def evaluate puts "evaluating" return super end Regards, David - -- The primary freedom of open source is not the freedom from cost, but the free- dom to shape software to do what you want. This freedom is /never/ exercised without cost, but is available /at all/ only by accepting the very different costs associated with open source, costs not in money, but in time and effort. - -- http://www.schierer.org/~luke/log/20070710-1129/on-forks-and-forking -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFG+NbK/Pp1N6Uzh0URAhbPAJ47IJsZoIWfjYDiDEDK5BFc2JEHbgCgh+NO pvmD0evrmxXNR1OS0MRhlpU=Up1K -----END PGP SIGNATURE-----