Class: Primitives::BlockBreaker

Inherits:
BlankSlate show all
Includes:
Inclusion
Defined in:
lib/extensions/primitives.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods included from Inclusion

#include, #run_block, #run_file

Constructor Details

#initialize(&block) ⇒ BlockBreaker

Returns a new instance of BlockBreaker.



34
35
36
37
38
39
40
# File 'lib/extensions/primitives.rb', line 34

def initialize(&block)
  if block_given?
    @handler = block
  else
    raise NoBlockGiven, "Must be a block to break!"
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



41
42
43
# File 'lib/extensions/primitives.rb', line 41

def method_missing(name, *args, &block)
  @handler.call(name, args, block) 
end