Module: Stall::Models::ProductList::ClassMethods

Defined in:
app/models/stall/models/product_list.rb

Instance Method Summary collapse

Instance Method Details

#aborted(options = {}) ⇒ Object

The .aborted and .finalized scopes cannot be declared as actual rails scopes since subclasses that override the .wizard method wouldn’t be taken into account, scopes being executed in the context of the declaring class



102
103
104
105
# File 'app/models/stall/models/product_list.rb', line 102

def aborted(options = {})
  where.not(state: wizard.steps.last)
    .older_than(options.fetch(:before, 1.day.ago))
end

#finalizedObject



107
108
109
# File 'app/models/stall/models/product_list.rb', line 107

def finalized
  where(state: wizard.steps.last)
end

#wizardObject



111
112
113
114
115
116
117
118
119
120
121
# File 'app/models/stall/models/product_list.rb', line 111

def wizard
  wizard_name = Stall.config.default_checkout_wizard

  if (wizard = Stall::Utils.try_load_constant(wizard_name))
    wizard
  else
    raise Stall::Checkout::WizardNotFoundError.new,
      "The checkout wizard #{ wizard_name } was not found. You must generate it " +
      "with `rails g stall:wizard #{ wizard_name.underscore.gsub('_checkout_wizard', '') }`"
  end
end