Module: Kernel

Defined in:
lib/fun_with/core_extensions/kernel.rb

Instance Method Summary collapse

Instance Method Details

#template_evaluator_set_local_vars(locals = {}, &block) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/fun_with/core_extensions/kernel.rb', line 2

def template_evaluator_set_local_vars( locals = {}, &block )
  old_local_vars = {}

  for k, v in locals
    var = :"@#{k}"
    old_local_vars[k] = instance_variable_get( var )
    instance_variable_set( var, v )
  end

  yield
ensure      # make all as it once was
  for k, v in old_local_vars
    var = :"@#{k}"
    instance_variable_set( var, v )
  end
end