Class: Spree::ProductScope

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/spree/product_scope/scopes.rb

Class Method Summary collapse

Class Method Details

.all_scopesObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/models/spree/product_scope/scopes.rb', line 10

def self.all_scopes
  {
    # Scopes for selecting products based on taxon
    :taxon => {
      :taxons_name_eq => [:taxon_name],
      :in_taxons => [:taxon_names],
    },
    # product selection based on name, or search
    :search => {
      :in_name => [:words],
      :in_name_or_keywords => [:words],
      :in_name_or_description => [:words],
      :with_ids => [:ids]
    },
    # Scopes for selecting products based on option types and properties
    :values => {
      :with => [:value],
      :with_property => [:property],
      :with_property_value => [:property, :value],
      :with_option => [:option],
      :with_option_value => [:option, :value],
    },
    # product selection based upon master price
    :price => {
      :price_between => [:low, :high],
      :master_price_lte => [:amount],
      :master_price_gte => [:amount],
    },
  }
end

.arguments_for_scope_name(name) ⇒ Object



41
42
43
44
45
# File 'app/models/spree/product_scope/scopes.rb', line 41

def self.arguments_for_scope_name(name)
  if group = all_scopes.detect { |k,v| v[name.to_sym] }
    group[1][name.to_sym]
  end
end