I assume you need one set of publishing_options for each class. In this case, you just want to prefix your variable with one @ . Remember that the class itself is an instance of the Class class, so when you are in the context of a class method, you really want to set the instance variable in your class. Something like the following:
module Publishable module ClassMethods def publishable(options) @publishing_options = options end def publishing_options @publishing_options end end def self.included(base) base.extend(ClassMethods) end end
Then, if ActiveRecord :: Base expands as follows:
ActiveRecord::Base.send :include, Publishable
You can do:
class Note < ActiveRecord::Base publishable :related_attributes => [:taggings] end class Other < ActiveRecord::Base publishable :related_attributes => [:other] end Note.publishing_options => {:related_attributes=>[:taggings]} Other.publishing_options => {:related_attributes=>[:other]}
mikej source share