Module: Ramaze::CoreExtensions::Binding
- Defined in:
- lib/ramaze/snippets/binding/locals.rb
Overview
Extensions for Binding
Instance Method Summary collapse
-
#locals ⇒ Object
Returns a hash of localvar/localvar-values from binding, useful for template engines that do not accept bindings and force passing locals via hash.
Instance Method Details
#locals ⇒ Object
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}
15 16 17 18 19 20 21 |
# File 'lib/ramaze/snippets/binding/locals.rb', line 15 def locals ::Kernel::eval ' local_variables.inject({}){|h,v| k = v.to_s h.merge!(k => eval(k)) }', self end |