Created
October 29, 2012 17:36
-
-
Save octosteve/3975095 to your computer and use it in GitHub Desktop.
Done with class_eval
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 Cart | |
def confirm | |
"Your order is being processed" | |
end | |
end | |
cart = Cart.new | |
cart.class.class_eval do | |
def deny | |
"Your order has been denied!" | |
end | |
end | |
cart.deny | |
#=> "Your order has been denied!" | |
next_cart = Cart.new | |
next_cart.deny | |
#=> "Your order has been denied!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment