Class: SpreeCmCommissioner::Places::FindWithRoute

Inherits:
Object
  • Object
show all
Defined in:
app/finders/spree_cm_commissioner/places/find_with_route.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(place_type:, place_id: nil, query: nil, route_type: nil) ⇒ FindWithRoute

Returns a new instance of FindWithRoute.



27
28
29
30
31
32
# File 'app/finders/spree_cm_commissioner/places/find_with_route.rb', line 27

def initialize(place_type:, place_id: nil, query: nil, route_type: nil)
  @place_type = place_type
  @place_id = place_id
  @query = query
  @route_type = route_type
end

Instance Attribute Details

#place_idObject (readonly)

Returns the value of attribute place_id.



25
26
27
# File 'app/finders/spree_cm_commissioner/places/find_with_route.rb', line 25

def place_id
  @place_id
end

#place_typeObject (readonly)

Returns the value of attribute place_type.



25
26
27
# File 'app/finders/spree_cm_commissioner/places/find_with_route.rb', line 25

def place_type
  @place_type
end

#queryObject (readonly)

Returns the value of attribute query.



25
26
27
# File 'app/finders/spree_cm_commissioner/places/find_with_route.rb', line 25

def query
  @query
end

#route_typeObject (readonly)

Returns the value of attribute route_type.



25
26
27
# File 'app/finders/spree_cm_commissioner/places/find_with_route.rb', line 25

def route_type
  @route_type
end

Instance Method Details

#executeObject



34
35
36
37
38
39
40
41
42
# File 'app/finders/spree_cm_commissioner/places/find_with_route.rb', line 34

def execute
  return SpreeCmCommissioner::Place.none if place_type.blank?
  return SpreeCmCommissioner::Place.none if place_id.present? && !SpreeCmCommissioner::Place.exists?(place_id)

  result = scope
  result = apply_query_filter(result) if query.present?
  result = apply_route_type_filter(result) if route_type.present?
  result
end