Sha256: 192d52e8e2955fb008dd541864340aceaf8b9554beb9c3279474a50fec478c09

Contents?: true

Size: 627 Bytes

Versions: 1

Compression:

Stored size: 627 Bytes

Contents

# frozen_string_literal: true
# On the fly delegation from the decorator to the decorated object and the helpers.
module ActiveDecorator
  module Helpers
    def method_missing(method, *args, &block)
      super
    rescue NoMethodError, NameError
      begin
        (view_context = ActiveDecorator::ViewContext.current).send method, *args, &block
      rescue NoMethodError
        raise NoMethodError, "undefined method `#{method}` for either #{self} or #{view_context}"
      rescue NameError
        raise NameError, "undefined local variable `#{method}` for either #{self} or #{view_context}"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_decorator-0.9.0 lib/active_decorator/helpers.rb