Hi --

On Fri, 18 Sep 2009, Dylan Lukes wrote:

>
>>
>> Of course, the problem is still there. What exactly do you want to do?
>> plugin is a class. Do you want an instance of it? If so:
>>
>>    plugin.new(self, CONFIG[plugin])
>>
>> One way or another, you need a method name.
>>
>>
>> David
>
>
> Okay, I fixed up my code with:
>
>    PLUGINS.each {|plugin| plugin = plugin.new(self, CONFIG[plugin])}
>
>
> The only issue is, on initializing I want it to do the following:
>
>  def initialize(server, config)
>       print "#{self} initialized with config:\n\n #{config}\n"
>  end
>
> For some reason though, config is coming up blank. I have defined config
> for BackupPlugin as a hash including an interval and directory key. The
> output shows nothing
>
> CONFIG = {
>  "BackupPlugin" => {
>    "interval" => (30 * 60),
>    "directory" => "backups"
>  }
> }
>
>
> OUTPUT:
>
> #<BackupPlugin:0x23f3c> initialized with config:
>
>
> #<MessagePlugin:0x23f28> initialized with config:
>
>
> #<KickPlugin:0x23ed8> initialized with config:
>
>
> Plugins started...

That's because CONFIG's keys are strings. Look at the rewrite I did
earlier; I changed them to class objects. There's no point doing a
round-trip to string if you really need the class.


David

-- 
David A. Black, Director
Ruby Power and Light, LLC (http://www.rubypal.com)
Ruby/Rails training, consulting, mentoring, code review
Book: The Well-Grounded Rubyist (http://www.manning.com/black2)