Brian Candler
2/26/2007 6:40:00 AM
On Mon, Feb 26, 2007 at 07:36:36AM +0900, Russell Fulton wrote:
> A bit more data:
>
> > My first attempt was to add a 'test' method to the
> > class which took the same parameters as initialize but just checked
> > them. Whenever I invoked Action::Nagios.test I got errors about not
> > being able to access private method 'test'.
>
> actual error is:
>
> private method `test' called for Action::Email:Class
>
> when invoked by:
>
> begin
> eval "test = Action::#{tok}.test(#{parms})" # known class
> ?
> rescue SyntaxError, StandardError =>e
> error( "bad paramers or unknown action #{tok}: #{e}")
> rest_of_line
> @errors = true
> end
Show the full class definition, including the method definition of 'test'.
It Works For Me [TM]:
irb(main):001:0> module Action
irb(main):002:1> class Email
irb(main):003:2> def self.test
irb(main):004:3> puts "Wibble"
irb(main):005:3> end
irb(main):006:2> end
irb(main):007:1> end
=> nil
irb(main):008:0> Action::Email.test
Wibble
=> nil
Note that you don't necessarily need to use 'eval':
irb(main):011:0> klass=Action.const_get('Email')
=> Action::Email
irb(main):012:0> klass.test
Wibble
=> nil