Class: SpreeCmCommissioner::SingleLegTripsQuery
- Inherits:
-
Object
- Object
- SpreeCmCommissioner::SingleLegTripsQuery
- Defined in:
- app/queries/spree_cm_commissioner/single_leg_trips_query.rb
Instance Attribute Summary collapse
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#destination_id ⇒ Object
readonly
Returns the value of attribute destination_id.
-
#number_of_guests ⇒ Object
readonly
Returns the value of attribute number_of_guests.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#origin_id ⇒ Object
readonly
Returns the value of attribute origin_id.
-
#route_type ⇒ Object
readonly
Returns the value of attribute route_type.
-
#tenant_id ⇒ Object
readonly
Returns the value of attribute tenant_id.
-
#vendor_id ⇒ Object
readonly
Returns the value of attribute vendor_id.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(origin_id:, destination_id:, date:, route_type: nil, vendor_id: nil, tenant_id: nil, number_of_guests: nil, options: {}) ⇒ SingleLegTripsQuery
constructor
rubocop:disable Metrics/ParameterLists.
Constructor Details
#initialize(origin_id:, destination_id:, date:, route_type: nil, vendor_id: nil, tenant_id: nil, number_of_guests: nil, options: {}) ⇒ SingleLegTripsQuery
rubocop:disable Metrics/ParameterLists
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/queries/spree_cm_commissioner/single_leg_trips_query.rb', line 22 def initialize(origin_id:, # rubocop:disable Metrics/ParameterLists destination_id:, date:, route_type: nil, vendor_id: nil, tenant_id: nil, number_of_guests: nil, options: {} ) @origin_id = origin_id @destination_id = destination_id @date = date.to_date == Time.zone.today ? Time.zone.now : Time.zone.parse(date.to_s) @vendor_id = vendor_id @tenant_id = tenant_id @number_of_guests = number_of_guests || 1 @route_type = route_type @options = end |
Instance Attribute Details
#date ⇒ Object (readonly)
Returns the value of attribute date.
18 19 20 |
# File 'app/queries/spree_cm_commissioner/single_leg_trips_query.rb', line 18 def date @date end |
#destination_id ⇒ Object (readonly)
Returns the value of attribute destination_id.
18 19 20 |
# File 'app/queries/spree_cm_commissioner/single_leg_trips_query.rb', line 18 def destination_id @destination_id end |
#number_of_guests ⇒ Object (readonly)
Returns the value of attribute number_of_guests.
18 19 20 |
# File 'app/queries/spree_cm_commissioner/single_leg_trips_query.rb', line 18 def number_of_guests @number_of_guests end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
18 19 20 |
# File 'app/queries/spree_cm_commissioner/single_leg_trips_query.rb', line 18 def @options end |
#origin_id ⇒ Object (readonly)
Returns the value of attribute origin_id.
18 19 20 |
# File 'app/queries/spree_cm_commissioner/single_leg_trips_query.rb', line 18 def origin_id @origin_id end |
#route_type ⇒ Object (readonly)
Returns the value of attribute route_type.
18 19 20 |
# File 'app/queries/spree_cm_commissioner/single_leg_trips_query.rb', line 18 def route_type @route_type end |
#tenant_id ⇒ Object (readonly)
Returns the value of attribute tenant_id.
18 19 20 |
# File 'app/queries/spree_cm_commissioner/single_leg_trips_query.rb', line 18 def tenant_id @tenant_id end |
#vendor_id ⇒ Object (readonly)
Returns the value of attribute vendor_id.
18 19 20 |
# File 'app/queries/spree_cm_commissioner/single_leg_trips_query.rb', line 18 def vendor_id @vendor_id end |
Instance Method Details
#call ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'app/queries/spree_cm_commissioner/single_leg_trips_query.rb', line 40 def call return [] if date < Date.current direct_trips.map do |trip| result = SpreeCmCommissioner::TripResult.from_trip(trip) SpreeCmCommissioner::TripQueryResult.new(trips: [result]) end end |