Frederick Cheung wrote:
> On Feb 25, 6:28�pm, Paul PH <li...@ruby-forum.com> wrote:
>> hi again, all.
>> I have the following plugin included in my active record model.
>> What i'd like to do, is define a method inside class_eval which returns
>> the options has that was passed into it via the acts_as_item :foo=>:bar
>> in my model.
>>
>> What i'm finding odd is that the self.foo method can access the config
>> hash when printing it, but not when i try to return it.
>>
> Two very different things are happening: with the puts config is being
> resolved just before class_eval is called: the string is interpolated
> and the result passed to class_eval.
> The return statement on the other hand is evaluated much later - when
> the foo method is actually called. config is no longer in scope and so
> you get an error.
> 
> Fred

Ah, I see - thanks Fred.
I understand the variable is resolved earlier to do the string 
interpolation. I do find it odd that it is put into scope for that, but 
not for returning it.

Thanks, again.
Paul.
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to