Class: Kernel::BlockBreaker
- Inherits:
-
BlankSlate
- Object
- BlankSlate
- Kernel::BlockBreaker
- Defined in:
- lib/extensions/kernel.rb
Instance Method Summary collapse
-
#initialize(&block) ⇒ BlockBreaker
constructor
A new instance of BlockBreaker.
- #method_missing(name, *args, &block) ⇒ Object
Constructor Details
#initialize(&block) ⇒ BlockBreaker
Returns a new instance of BlockBreaker.
25 26 27 28 29 30 31 |
# File 'lib/extensions/kernel.rb', line 25 def initialize(&block) if block_given? @handler = block else raise NoBlockGiven, "Must be a block to whine to" end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
33 34 35 |
# File 'lib/extensions/kernel.rb', line 33 def method_missing(name, *args, &block) @handler.call(name, args, block) end |