Class: SerializableProc::Binding

Inherits:
Object
  • Object
show all
Includes:
Isolatable, Marshalable
Defined in:
lib/serializable_proc/binding.rb

Constant Summary

Constants included from Isolatable

Isolatable::BLOCK_SCOPES, Isolatable::ISOLATION_VAR, Isolatable::MAPPERS

Instance Method Summary collapse

Methods included from Marshalable

included

Constructor Details

#initialize(binding, sexp) ⇒ Binding

Returns a new instance of Binding.



11
12
13
14
15
# File 'lib/serializable_proc/binding.rb', line 11

def initialize(binding, sexp)
  @vars = isolatable_vars(sexp).inject({}) do |memo, (o_var, n_var)|
    memo.merge(n_var => bounded_val(o_var, binding))
  end
end

Instance Method Details

#eval!(binding = nil) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/serializable_proc/binding.rb', line 17

def eval!(binding = nil)
  unless binding
    @binding ||= (
      eval(declare_vars, binding = Kernel.binding)
      binding
    )
  else
    eval(declare_vars, binding)
    binding
  end
end