Class: SpreeCmCommissioner::VendorStopPlaceQuery

Inherits:
Object
  • Object
show all
Defined in:
app/queries/spree_cm_commissioner/vendor_stop_place_query.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(query:, vendor_id:, stop_type: :boarding, reference_stop_id: nil) ⇒ VendorStopPlaceQuery

Returns a new instance of VendorStopPlaceQuery.



5
6
7
8
9
10
# File 'app/queries/spree_cm_commissioner/vendor_stop_place_query.rb', line 5

def initialize(query:, vendor_id:, stop_type: :boarding, reference_stop_id: nil)
  @query = query.to_s.strip
  @vendor_id = vendor_id
  @stop_type = stop_type
  @reference_stop_id = reference_stop_id
end

Instance Attribute Details

#queryObject (readonly)

Returns the value of attribute query.



3
4
5
# File 'app/queries/spree_cm_commissioner/vendor_stop_place_query.rb', line 3

def query
  @query
end

#reference_stop_idObject (readonly)

Returns the value of attribute reference_stop_id.



3
4
5
# File 'app/queries/spree_cm_commissioner/vendor_stop_place_query.rb', line 3

def reference_stop_id
  @reference_stop_id
end

#stop_typeObject (readonly)

Returns the value of attribute stop_type.



3
4
5
# File 'app/queries/spree_cm_commissioner/vendor_stop_place_query.rb', line 3

def stop_type
  @stop_type
end

#vendor_idObject (readonly)

Returns the value of attribute vendor_id.



3
4
5
# File 'app/queries/spree_cm_commissioner/vendor_stop_place_query.rb', line 3

def vendor_id
  @vendor_id
end

Instance Method Details

#callObject



12
13
14
15
16
17
18
19
# File 'app/queries/spree_cm_commissioner/vendor_stop_place_query.rb', line 12

def call
  results = vendor_stops
  return [] if results.empty?

  places = results.includes(:stop).map(&:stop).compact.uniq

  format_places(places)
end