Class: Spree::Taxons::Find

Inherits:
Object
  • Object
show all
Defined in:
app/finders/spree/taxons/find.rb

Instance Method Summary collapse

Constructor Details

#initialize(scope:, params:) ⇒ Find

Returns a new instance of Find.



4
5
6
7
8
9
10
11
12
# File 'app/finders/spree/taxons/find.rb', line 4

def initialize(scope:, params:)
  @scope = scope
  @ids              = String(params.dig(:filter, :ids)).split(',')
  @parent           = params.dig(:filter, :parent_id)
  @parent_permalink = params.dig(:filter, :parent_permalink)
  @taxonomy         = params.dig(:filter, :taxonomy_id)
  @name             = params.dig(:filter, :name)
  @roots            = params.dig(:filter, :roots)
end

Instance Method Details

#executeObject



14
15
16
17
18
19
20
21
22
23
# File 'app/finders/spree/taxons/find.rb', line 14

def execute
  taxons = by_ids(scope)
  taxons = by_parent(taxons)
  taxons = by_parent_permalink(taxons)
  taxons = by_taxonomy(taxons)
  taxons = by_roots(taxons)
  taxons = by_name(taxons)

  taxons.distinct
end