Sha256: aade060851f2a2d3ffdecef301d803b8f601f9cc2eb2526db9d290128af08082
Contents?: true
Size: 918 Bytes
Versions: 3
Compression:
Stored size: 918 Bytes
Contents
module Draper # Provides access to helper methods - both Rails built-in helpers, and those # defined in your application. class HelperProxy # @overload initialize(view_context) def initialize(view_context) @view_context = view_context end # Sends helper methods to the view context. def method_missing(method, *args, &block) self.class.define_proxy method send(method, *args, &block) end # Checks if the context responds to an instance method, or is able to # proxy it to the view context. def respond_to_missing?(method, include_private = false) super || view_context.respond_to?(method) end delegate :capture, to: :view_context protected attr_reader :view_context private def self.define_proxy(name) define_method name do |*args, &block| view_context.send(name, *args, &block) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
draper-4.0.1 | lib/draper/helper_proxy.rb |
draper-4.0.0 | lib/draper/helper_proxy.rb |
draper-3.1.0 | lib/draper/helper_proxy.rb |