module Spree::Core::StateMachines::Order
Public Class Methods
included(klass)
click to toggle source
# File lib/spree/core/state_machines/order.rb, line 7 def self.included(klass) klass.extend ClassMethods end
Public Instance Methods
can_go_to_state?(state)
click to toggle source
# File lib/spree/core/state_machines/order.rb, line 241 def can_go_to_state?(state) return false unless has_checkout_step?(self.state) && has_checkout_step?(state) checkout_step_index(state) > checkout_step_index(self.state) end
checkout_step_index(step)
click to toggle source
# File lib/spree/core/state_machines/order.rb, line 237 def checkout_step_index(step) checkout_steps.index(step).to_i end
checkout_steps()
click to toggle source
# File lib/spree/core/state_machines/order.rb, line 218 def checkout_steps steps = self.class.checkout_steps.each_with_object([]) { |(step, options), checkout_steps| next if options.include?(:if) && !options[:if].call(self) checkout_steps << step }.map(&:to_s) # Ensure there is always a complete step steps << "complete" unless steps.include?("complete") steps end
has_checkout_step?(step)
click to toggle source
# File lib/spree/core/state_machines/order.rb, line 229 def has_checkout_step?(step) step.present? && checkout_steps.include?(step) end
passed_checkout_step?(step)
click to toggle source
# File lib/spree/core/state_machines/order.rb, line 233 def passed_checkout_step?(step) has_checkout_step?(step) && checkout_step_index(step) < checkout_step_index(state) end