Merge pull request #195 from nashby/singleton
use singleton_class since we drop ruby < 1.9.3 support
This commit is contained in:
commit
aa6bd67614
|
@ -10,11 +10,9 @@ module Draper::ActiveModelSupport
|
||||||
|
|
||||||
proxies.each do |method_name, dependency|
|
proxies.each do |method_name, dependency|
|
||||||
if base.model.kind_of?(dependency) || dependency.nil?
|
if base.model.kind_of?(dependency) || dependency.nil?
|
||||||
class << base
|
base.singleton_class.class_eval do
|
||||||
self
|
|
||||||
end.class_eval do
|
|
||||||
if !base.class.instance_methods.include?(method_name) || base.class.instance_method(method_name).owner === Draper::Base
|
if !base.class.instance_methods.include?(method_name) || base.class.instance_method(method_name).owner === Draper::Base
|
||||||
send(:define_method, method_name) do |*args, &block|
|
define_method(method_name) do |*args, &block|
|
||||||
model.send(method_name, *args, &block)
|
model.send(method_name, *args, &block)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,8 +11,6 @@ module Draper
|
||||||
self.denied = DEFAULT_DENIED
|
self.denied = DEFAULT_DENIED
|
||||||
self.allowed = DEFAULT_ALLOWED
|
self.allowed = DEFAULT_ALLOWED
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Initialize a new decorator instance by passing in
|
# Initialize a new decorator instance by passing in
|
||||||
# an instance of the source class. Pass in an optional
|
# an instance of the source class. Pass in an optional
|
||||||
# context inside the options hash is stored for later use.
|
# context inside the options hash is stored for later use.
|
||||||
|
|
Loading…
Reference in New Issue