class Draper::HelperProxy

Provides access to helper methods - both Rails built-in helpers, and those defined in your application.

Attributes

view_context[R]

Public Class Methods

new(view_context) click to toggle source

@overload initialize(view_context)

# File lib/draper/helper_proxy.rb, line 6
def initialize(view_context)
  @view_context = view_context
end

Private Class Methods

define_proxy(name) click to toggle source
# File lib/draper/helper_proxy.rb, line 30
def self.define_proxy(name)
  define_method name do |*args, &block|
    view_context.send(name, *args, &block)
  end
  ruby2_keywords name
end

Public Instance Methods

method_missing(method, *args, &block) click to toggle source
# File lib/draper/helper_proxy.rb, line 11
               def method_missing(method, *args, &block)
  self.class.define_proxy method
  send(method, *args, &block)
end
respond_to_missing?(method, include_private = false) click to toggle source

Checks if the context responds to an instance method, or is able to proxy it to the view context.

Calls superclass method
# File lib/draper/helper_proxy.rb, line 18
def respond_to_missing?(method, include_private = false)
  super || view_context.respond_to?(method)
end