2011-11-29 14:29:11 -05:00
|
|
|
require "./performance/models"
|
2012-10-09 04:51:40 -04:00
|
|
|
class ProductDecorator < Draper::Decorator
|
2011-11-29 14:29:11 -05:00
|
|
|
decorates :product
|
2012-02-13 10:24:31 -05:00
|
|
|
|
2011-11-29 14:29:11 -05:00
|
|
|
def awesome_title
|
|
|
|
"Awesome Title"
|
|
|
|
end
|
2012-02-13 10:24:31 -05:00
|
|
|
|
2011-11-29 14:29:11 -05:00
|
|
|
# Original #method_missing
|
|
|
|
def method_missing(method, *args, &block)
|
|
|
|
if allow?(method)
|
|
|
|
begin
|
|
|
|
model.send(method, *args, &block)
|
|
|
|
rescue NoMethodError
|
|
|
|
super
|
|
|
|
end
|
|
|
|
else
|
|
|
|
super
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2012-10-09 04:51:40 -04:00
|
|
|
class FastProductDecorator < Draper::Decorator
|
2011-11-29 14:29:11 -05:00
|
|
|
decorates :product
|
2012-02-13 10:24:31 -05:00
|
|
|
|
2011-11-29 14:29:11 -05:00
|
|
|
def awesome_title
|
|
|
|
"Awesome Title"
|
|
|
|
end
|
2012-02-13 10:24:31 -05:00
|
|
|
|
2011-11-29 14:29:11 -05:00
|
|
|
# Modified #method_missing
|
|
|
|
def method_missing(method, *args, &block)
|
|
|
|
if allow?(method)
|
|
|
|
begin
|
|
|
|
self.class.send :define_method, method do |*args, &block|
|
|
|
|
model.send(method, *args, &block)
|
|
|
|
end
|
|
|
|
self.send(method, *args, &block)
|
|
|
|
rescue NoMethodError
|
|
|
|
super
|
|
|
|
end
|
|
|
|
else
|
|
|
|
super
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|