Class: Spree::CollectionRules::Sale

Inherits:
Spree::CollectionRule show all
Defined in:
app/models/spree/collection_rules/sale.rb

Constant Summary

Constants inherited from Spree::CollectionRule

Spree::CollectionRule::MATCH_POLICIES

Instance Method Summary collapse

Methods included from TypeLabels

#human_description, #human_name

Instance Method Details

#apply(scope) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'app/models/spree/collection_rules/sale.rb', line 6

def apply(scope)
  case match_policy
  when 'is_equal_to', 'contains'
    scope.on_sale(store.default_currency)
  when 'is_not_equal_to', 'does_not_contain'
    scope.where.not(id: scope.on_sale(store.default_currency))
  else
    scope
  end
end