Skip to content

Instantly share code, notes, and snippets.

@EmmanuelOga
Created January 4, 2010 22:56
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 EmmanuelOga/268946 to your computer and use it in GitHub Desktop.
Save EmmanuelOga/268946 to your computer and use it in GitHub Desktop.
A piece of crap.
# This is crap. :o
# Why did I code this? I should have know better.
# only in ruby 1.9
class Stringificator < BasicObject
Signature = " > a hidden method < "
define_method(Signature) { ::Kernel.binding }
def method_missing(x)
x.to_s
end
end
def hashify(str)
Kernel.eval("{ #{ str } }", Stringificator.new.__send__(Stringificator::Signature))
end
puts hashify('a:b, c:d')
puts hashify('a:b, c:d').class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment