Class: Anaphora::Proxy

Inherits:
BlankSlate show all
Defined in:
lib/anaphora.rb

Instance Method Summary collapse

Constructor Details

#initializeProxy

Returns a new instance of Proxy.



14
15
16
# File 'lib/anaphora.rb', line 14

def initialize
  @methods = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



22
23
24
25
26
# File 'lib/anaphora.rb', line 22

def method_missing(name, *args, &block)
  return true if name == :respond_to? && args.first == :to_proc
  @methods << MethodInvocation.new(name, args, block)
  self
end

Instance Method Details

#to_procObject



18
19
20
# File 'lib/anaphora.rb', line 18

def to_proc
  lambda {|it| @methods.inject(it) {|target, method| method.send_to(target) }}
end