On 3/11/07, bcparanj / gmail.com <bcparanj / gmail.com> wrote: > I followed the online tutorials on how to write plugins. So I have > acts_as_fox.rb: > > require 'active_record' > > module Foo > module Acts #:nodoc: > module Fox #:nodoc: > > def self.included(mod) > mod.extend(ClassMethods) > end > > # declare the class level helper methods which > # will load the relevant instance methods > # defined below when invoked > module ClassMethods > def acts_as_fox > class_eval do > extend Foo::Acts::Fox::SingletonMethods > end > include Foo::Acts::Fox::InstanceMethods > end > end > > # Adds a catch_chickens class method which finds > # all records which have a 'chickens' field set > # to true. > module SingletonMethods > def catch_chickens > find(:all, :conditions => ['chickens = ?', true]) > end > # etc... > end > > # Adds instance methods. > module InstanceMethods > def eat_chicken > puts "Fox with ID #{self.id} just ate a chicken" > end > end > > end > end > end > > # reopen ActiveRecord and include all the above to make > # them available to all our models if they want it > > ActiveRecord::Base.class_eval do > include Foo::Acts::Fox > end > > and Thing.rb > > class Thing < ActiveRecord::Base > acts_as_fox > end > > > My question I want to change the acts_as_fox to something like: > > acts_as_fox :pass_something > > where I can pass a symbol as a value to the acts_as_fox method. > > I tried to modify the working example with no luck. Can someone please > point me in the right direction? Don't know anything about plugins, though I suppose module ClassMethods def acts_as_fox(arg) do_something(arg) class_eval do extend Foo::Acts::Fox::SingletonMethods end include Foo::Acts::Fox::InstanceMethods end end should suffice. If it doesn't work, please specify 1. what are you trying to achieve, 2. what did you try (preferably include the code) and 3. what did you get (include error messages and/or describe the wrong behaviour) This code is a copy-paste from the tutorial. To find out what's wrong it's important to see your changes.