Module: Spree::Order::Checkout
- Defined in:
- app/models/spree/order/checkout.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #can_go_to_state?(state) ⇒ Boolean
- #checkout_step_index(step) ⇒ Object
- #checkout_steps ⇒ Object
- #has_checkout_step?(step) ⇒ Boolean
- #passed_checkout_step?(step) ⇒ Boolean
Class Method Details
.included(klass) ⇒ Object
6 7 8 |
# File 'app/models/spree/order/checkout.rb', line 6 def self.included(klass) klass.extend ClassMethods end |
Instance Method Details
#can_go_to_state?(state) ⇒ Boolean
238 239 240 241 |
# File 'app/models/spree/order/checkout.rb', line 238 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) ⇒ Object
234 235 236 |
# File 'app/models/spree/order/checkout.rb', line 234 def checkout_step_index(step) checkout_steps.index(step).to_i end |
#checkout_steps ⇒ Object
216 217 218 219 220 221 222 223 224 |
# File 'app/models/spree/order/checkout.rb', line 216 def checkout_steps steps = self.class.checkout_steps.each_with_object([]) { |(step, ), checkout_steps| next if .include?(:if) && ![: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) ⇒ Boolean
226 227 228 |
# File 'app/models/spree/order/checkout.rb', line 226 def has_checkout_step?(step) step.present? && checkout_steps.include?(step) end |
#passed_checkout_step?(step) ⇒ Boolean
230 231 232 |
# File 'app/models/spree/order/checkout.rb', line 230 def passed_checkout_step?(step) has_checkout_step?(step) && checkout_step_index(step) < checkout_step_index(state) end |