Skip to content

Instantly share code, notes, and snippets.

@nicholasjhenry
Created May 28, 2011 19:46
Show Gist options
  • Select an option

  • Save nicholasjhenry/997153 to your computer and use it in GitHub Desktop.

Select an option

Save nicholasjhenry/997153 to your computer and use it in GitHub Desktop.
DCI Example
class CheckoutController
def new
checkout = ChecktoutContext.new
@order = checkout.order
end
end
class CheckoutContext
def initialize
@order = Order.new
@order.send(:include, CheckoutRole)
end
end
module CheckoutRole
# methods related to checkout
extend ActiveSupport::Concern
module InstanceMethods
def finalize!
# ...
end
end
end
class Order
# ...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment