Class: Spree::TaxonBrandSelector

Inherits:
Object
  • Object
show all
Defined in:
app/models/spree/taxon_brand_selector.rb

Constant Summary collapse

BRANDS_TAXONOMY_NAME =
"Brands"

Instance Method Summary collapse

Constructor Details

#initialize(product) ⇒ TaxonBrandSelector

Returns a new instance of TaxonBrandSelector.



7
8
9
# File 'app/models/spree/taxon_brand_selector.rb', line 7

def initialize(product)
  @product = product
end

Instance Method Details

#callObject



11
12
13
14
15
16
# File 'app/models/spree/taxon_brand_selector.rb', line 11

def call
  product.taxons
         .joins(:taxonomy)
         .where(spree_taxonomies: { name: BRANDS_TAXONOMY_NAME })
         .first
end