Class: Binding

Inherits:
Object show all
Defined in:
lib/ramaze/snippets/binding/locals.rb

Instance Method Summary collapse

Instance Method Details

#localsObject

returns a hash of localvar/localvar-values from binding, useful for template engines that do not accept bindings and force passing locals via hash

usage: x = 42; p binding.locals #=> {'x'=> 42}


7
8
9
10
11
# File 'lib/ramaze/snippets/binding/locals.rb', line 7

def locals
  Kernel::eval '
    local_variables.inject({}){|h,v| h.update v => eval(v)}
  ', self
end