Skip to content

Instantly share code, notes, and snippets.

@dmcclory
Created June 19, 2014 23:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmcclory/f754d555e864ac25a0b0 to your computer and use it in GitHub Desktop.
Save dmcclory/f754d555e864ac25a0b0 to your computer and use it in GitHub Desktop.
get a hash of local variables from a binding
def hash_for_binding(b)
vars = b.eval('local_variables')
vars.inject({}) { |memo, var|
memo[var] = b.eval(var.to_s)
memo
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment