Skip to content

Instantly share code, notes, and snippets.

@skwp
Created August 8, 2013 14:19
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skwp/6184992 to your computer and use it in GitHub Desktop.
Save skwp/6184992 to your computer and use it in GitHub Desktop.
def create
checkout = CheckoutOrder.new current_user, params
checkout.subscribe(AnalyticsListener.new)
checkout.on(:checkout_success) do |order|
respond_with ...
end
checkout.on(:checkout_failed_for_one_reason) do |order|
do_a_thing...
end
checkout.on(:checkout_failed_for_another_reason) do |order|
do_a_thing...
end
checkout.do_checkout
end
class AnalyticsListener
def checkout_success
# notify google analytics / kissmetrics
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment