Skip to content

Instantly share code, notes, and snippets.

@octosteve
Created October 29, 2012 17:27
Show Gist options
  • Save octosteve/3975053 to your computer and use it in GitHub Desktop.
Save octosteve/3975053 to your computer and use it in GitHub Desktop.
Conventional way to add methods to a class
class Cart
def confirm
"Your order is being processed"
end
end
cart = Cart.new
# then reopen the class
class Cart
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