Sha256: c540634c443dc9ab5c6bb6850bf26fb8bb26f74d5fcecf5beaefd48d43d362bf

Contents?: true

Size: 344 Bytes

Versions: 2

Compression:

Stored size: 344 Bytes

Contents

class Binding

  # 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}
  def locals
    Kernel::eval '
      local_variables.inject({}){|h,v| h.update v => eval(v)}
    ', self
  end

end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
clivecrous-ramaze-0.3.9.5 lib/ramaze/snippets/binding/locals.rb
ramaze-2008.06 lib/ramaze/snippets/binding/locals.rb