Class: Binding::BlockEnvironment

Inherits:
BasicObject
Defined in:
lib/standard/facets/binding/block_exec.rb

Overview

This class is used for evaluating blocks in a particular context. It is not really meant to be used independently; instead it is used with Binding#block_exec method.

Instance Method Summary collapse

Constructor Details

#initialize(context, *args, &block) ⇒ BlockEnvironment

Returns a new instance of BlockEnvironment.



28
29
30
31
32
# File 'lib/standard/facets/binding/block_exec.rb', line 28

def initialize(context, *args, &block)
  @context = context
  @args = args
  @block = block
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name) ⇒ Object



38
39
40
# File 'lib/standard/facets/binding/block_exec.rb', line 38

def method_missing(name)
  eval(name.to_s, @context) rescue super
end

Instance Method Details

#callObject



34
35
36
# File 'lib/standard/facets/binding/block_exec.rb', line 34

def call
  instance_exec(*@args, &@block)
end