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_file

Constructor Details

#initialize(&block) ⇒ BlockBreaker

Returns a new instance of BlockBreaker.



30
31
32
33
34
35
36
# File 'lib/extensions/primitives.rb', line 30

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



37
38
39
# File 'lib/extensions/primitives.rb', line 37

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