Class: Uberscore::Context
- Inherits:
- BasicObject
- Defined in:
- lib/uberscore.rb
Instance Method Summary collapse
-
#initialize ⇒ Context
constructor
A new instance of Context.
- #method_missing(name, *args, &block) ⇒ Object
- #to_proc ⇒ Object
Constructor Details
#initialize ⇒ Context
Returns a new instance of Context.
17 18 19 |
# File 'lib/uberscore.rb', line 17 def initialize @call_chain = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
21 22 23 24 |
# File 'lib/uberscore.rb', line 21 def method_missing(name, *args, &block) @call_chain << [name, args, block] self end |
Instance Method Details
#to_proc ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/uberscore.rb', line 26 def to_proc ->(object) do @call_chain.reduce(object) do |block_parameter, (method_name, method_arguments, block)| block_parameter.public_send(method_name, *method_arguments, &block) end end end |