Skip to content

Instantly share code, notes, and snippets.

@perezd
Created April 21, 2009 02:17
Show Gist options
  • Save perezd/98892 to your computer and use it in GitHub Desktop.
Save perezd/98892 to your computer and use it in GitHub Desktop.
Hackish Prototype of a JavaScript-esque Class/Object
class Hash
def method_missing(meth,*args)
self[meth].is_a?(Proc) ? self[meth].call(*args) : self[meth]
end
end
MyClass = {
:some_method => lambda { |arg|
puts "#{arg} was recieved"
}
}
MyClass.some_method('hello world')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment