Module: Hoodie::Proxy::Methods

Defined in:
lib/hoodie/proxy.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/hoodie/proxy.rb', line 51

def method_missing(method_name, *args, &block)
  if __proxy_target__.respond_to?(method_name)
    response = __proxy_target__.public_send(method_name, *args, &block)

    if response.equal?(__proxy_target__)
      self
    elsif response.kind_of?(__proxy_kind__)
      self.class.new(*[response]+__proxy_args__)
    else
      response
    end
  else
    super
  end
end

Instance Method Details

#respond_to_missing?(method_name, include_private) ⇒ Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/hoodie/proxy.rb', line 47

def respond_to_missing?(method_name, include_private)
  __proxy_target__.respond_to?(method_name, include_private)
end