Define proxy using `send` instead of `delegate`

Rails 4 will not delegate non-public methods
This commit is contained in:
Andrew Haines 2013-01-24 01:15:16 +00:00
parent e6f88a5e7d
commit 38c929b818
1 changed files with 7 additions and 1 deletions

View File

@ -12,7 +12,7 @@ module Draper
# Sends helper methods to the view context.
def method_missing(method, *args, &block)
self.class.delegate method, to: :view_context
self.class.define_proxy method
send(method, *args, &block)
end
@ -22,6 +22,12 @@ module Draper
private
def self.define_proxy(name)
define_method name do |*args, &block|
view_context.send(name, *args, &block)
end
end
def current_view_context
ActiveSupport::Deprecation.warn("wrong number of arguments (0 for 1) passed to Draper::HelperProxy.new", caller[1..-1])
Draper::ViewContext.current.view_context