Created
April 21, 2009 02:17
-
-
Save perezd/98892 to your computer and use it in GitHub Desktop.
Hackish Prototype of a JavaScript-esque Class/Object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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