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.
16 17 18 |
# File 'lib/uberscore.rb', line 16 def initialize @call_chain = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
20 21 22 23 |
# File 'lib/uberscore.rb', line 20 def method_missing(name, *args, &block) @call_chain << [name, args, block] self end |
Instance Method Details
#to_proc ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/uberscore.rb', line 25 def to_proc ->(object) do @call_chain.reduce(object) do |current, (name, args, block)| current.public_send(name, *args, &block) end end end |