-
-
Save kivanio/8a541ab9abfa7fc05ed3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module States | |
extend ActiveSupport::Concern | |
included do | |
state_machine :status, :initial => :new do | |
event :confirm do | |
transition :new => :confirmed #, :if => lambda {|order| order.email.present?} | |
end | |
before_transition :new => :confirmed do |order| | |
order.send :email_confirmation | |
#order.send :notify | |
end | |
event :invoice do | |
transition :confirmed => :invoiced | |
end | |
before_transition :confirmed => :invoiced do |order| | |
#order.send :create_invoice | |
#order.send :email_invoice | |
#order.send :invoice_alert | |
#order.send :notify | |
end | |
event :pay do | |
transition :invoiced => :paid | |
end | |
before_transition :invoiced => :paid do |order| | |
#order.send :email_paid | |
#order.send :notify | |
end | |
end | |
end | |
module InstanceMethods | |
def email_confirmation | |
UserMailer.order_confirmed(self).deliver | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment