------Original Message------
From: Rick DeNatale
Sender: rubyonrails-talk@googlegroups.com
To: rubyonrails-talk@googlegroups.com
ReplyTo: rubyonrails-talk@googlegroups.com
Subject: Re: [Rails] Rails acts_as_* plugins, with parameters
Sent: Feb 25, 2010 20:08

On Thu, Feb 25, 2010 at 7:32 AM, Paul PH <li...@ruby-forum.com> wrote:
> Hi all,
> I'm trying to write a plugin which will allow me to specify:
> acts_as_item :option=>:value
>
> i need to be able to access the :options=>:value hash from instances of
> the model also.
> I've tried with class_eval in the plugin, but can't get it working.
> I'm calling acts_as_item(options), and that method can see the options
> passed from a model. Then  inside the class_eval, I'm adding a method
> (def self.configuration) which returns the options hash. I thought from
> an instance, I'd be able to do instance.class.configuration which would
> then return said options hash.
>
> Any ideas?
> thanks for reading.
>
> module Item
>    #called by active record for us
>    def self.included(base)
>      base.extend ClassMethods
>    end
>
>    module ClassMethods
>      def acts_as_item(options = {})
>        configuration = {:option=>:value}
>        class_eval {
>          include InstanceMethods
>
>          def self.configuration
I think you want this to be
            def configuration

Since this is in a module extended by the class.


-- 
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale

-- 
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.


-- 
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