79. Book Object
(Class) (Class)
acts_as_product
2010 8 28
80. Book Object
(Class) (Class)
acts_as_product
2010 8 28
81. Book Object
(Class) (Class)
acts_as_product
Product
2010 8 28
82. the easier way
class Object
def self.acts_as_product
include Product
end
end
the caller (Book) will be self here
2010 8 28
83. Book
(Class)
class Book
acts_as_product
...
end
Product
2010 8 28
84. class Object
def self.acts_as_product
include Product
end
end
Execute this before acts_as_product is invoked
Rails config/initializer/acts_as_product.rb
2010 8 28
85. the softer way
module ActsAsProduct
module ClassMethods
def acts_as_product
include Product
end
end
def self.included(base)
base.extend(ClassMethods)
end
end
Object.instance_eval { include ActsAsProduct }
2010 8 28