Skip to content

Instantly share code, notes, and snippets.

@octosteve
Created October 29, 2012 17:36
Show Gist options
  • Save octosteve/3975095 to your computer and use it in GitHub Desktop.
Save octosteve/3975095 to your computer and use it in GitHub Desktop.
Done with class_eval
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