Sha256: a15cdfee2e4b6a38d955ce28212f1eb54abcf82d297879cf526c63f2e00e4c99

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

require 'spree_core'
require 'spree_paypal_website_standard_hooks'

module SpreePaypalWebsiteStandard
  class Engine < Rails::Engine

    config.autoload_paths += %W(#{config.root}/lib)

    def self.activate
      Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c|
        Rails.env.production? ? require(c) : load(c)
      end
      
      # add new events and states to the FSM
=begin
      fsm = Order.state_machines[:state]  
      fsm.events << StateMachine::Event.new(fsm, "fail_payment")
      fsm.events["fail_payment"].transition(:to => 'payment_failure', :from => ['in_progress', 'payment_pending'])
  
      fsm.events << StateMachine::Event.new(fsm, "pend_payment")
      fsm.events["pend_payment"].transition(:to => 'payment_pending', :from => 'in_progress')    
      fsm.after_transition(:to => 'payment_pending', :do => lambda {|order| order.update_attribute(:checkout_complete, true)})  
  
      fsm.events["pay"].transition(:to => 'paid', :from => ['payment_pending', 'in_progress'])
=end
    end

    config.to_prepare &method(:activate).to_proc
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spree_paypal_website_standard-0.8.4 lib/spree_paypal_website_standard.rb
spree_paypal_website_standard-0.8.3 lib/spree_paypal_website_standard.rb