Module: SolidusDrip::Spree::OrderDecorator
- Defined in:
- app/decorators/models/solidus_drip/spree/order_decorator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #drip ⇒ Object
-
#update_drip_activity ⇒ Object
Updates activity on Drip.
Class Method Details
.prepended(base) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'app/decorators/models/solidus_drip/spree/order_decorator.rb', line 6 def self.prepended(base) base.after_create(proc { |order| order.drip.cart_activity('created') }) base.state_machine.after_transition(to: :complete, do: proc { |order| order.drip.order_activity('placed') }) base.state_machine.after_transition(to: :canceled, do: proc { |order| order.drip.order_activity('canceled') }) end |
Instance Method Details
#drip ⇒ Object
40 41 42 |
# File 'app/decorators/models/solidus_drip/spree/order_decorator.rb', line 40 def drip @drip ||= SolidusDrip::ShopperActivity::Order.new(self) end |
#update_drip_activity ⇒ Object
Updates activity on Drip
This method is called as part of the Spree::Order.update_hooks
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/decorators/models/solidus_drip/spree/order_decorator.rb', line 25 def update_drip_activity # If the order is complete it is no longer considered cart data if completed? if shipment_state_changed? && shipped? drip.order_activity('fulfilled') end if payment_state_changed? && paid? drip.order_activity('paid') end drip.order_activity('updated') else drip.cart_activity('updated') end end |