module Enrich::AutoDelegate

Public Instance Methods

delegatable?(method) click to toggle source
# File lib/enrich/auto_delegate.rb, line 21
def delegatable?(method)
  object.respond_to?(method)
end
method_missing(method, *args, &block) click to toggle source

Delegates missing instance methods to the source object.

Calls superclass method
# File lib/enrich/auto_delegate.rb, line 8
def method_missing(method, *args, &block)
  return super unless delegatable?(method)

  # self.singleton_class.delegate method, to: :object
  object.send(method, *args, &block)
end
respond_to_missing?(method, include_private = false) click to toggle source

Checks if the decorator responds to an instance method, or is able to proxy it to the source object.

Calls superclass method
# File lib/enrich/auto_delegate.rb, line 17
def respond_to_missing?(method, include_private = false)
  super || delegatable?(method)
end