Class: Anaphora::Proxy
- Inherits:
-
BlankSlate
- Object
- BlankSlate
- Anaphora::Proxy
- Defined in:
- lib/anaphora.rb
Instance Method Summary collapse
-
#initialize ⇒ Proxy
constructor
A new instance of Proxy.
- #method_missing(name, *args, &block) ⇒ Object
- #to_proc ⇒ Object
Constructor Details
#initialize ⇒ Proxy
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_proc ⇒ Object
18 19 20 |
# File 'lib/anaphora.rb', line 18 def to_proc lambda {|it| @methods.inject(it) {|target, method| method.send_to(target) }} end |