Class: SpreeCmCommissioner::Route
- Inherits:
-
Base
- Object
- Spree::Base
- Base
- SpreeCmCommissioner::Route
show all
- Includes:
- RouteType
- Defined in:
- app/models/spree_cm_commissioner/route.rb
Constant Summary
Constants included
from RouteType
SpreeCmCommissioner::RouteType::ROUTE_TYPES
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.ransackable_attributes(_auth_object = nil) ⇒ Object
44
45
46
|
# File 'app/models/spree_cm_commissioner/route.rb', line 44
def self.ransackable_attributes(_auth_object = nil)
%w[route_type short_name route_name]
end
|
Instance Method Details
#max_price_for(currency) ⇒ Object
40
41
42
|
# File 'app/models/spree_cm_commissioner/route.rb', line 40
def max_price_for(currency)
route_prices.for_currency(currency).find_by(price_type: :max_price)&.price
end
|
#min_price_for(currency) ⇒ Object
36
37
38
|
# File 'app/models/spree_cm_commissioner/route.rb', line 36
def min_price_for(currency)
route_prices.for_currency(currency).find_by(price_type: :min_price)&.price
end
|
#prices_for(currency) ⇒ Object
32
33
34
|
# File 'app/models/spree_cm_commissioner/route.rb', line 32
def prices_for(currency)
route_prices.for_currency(currency)
end
|
#route_stops=(value) ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
|
# File 'app/models/spree_cm_commissioner/route.rb', line 52
def route_stops=(value)
if value.is_a?(Transit::RouteStopCollection)
@route_stops = value
self[:route_stops] = value.to_h
elsif value.is_a?(Array)
@route_stops = Transit::RouteStopCollection.from_hash(value)
self[:route_stops] = @route_stops.to_h
else
raise ArgumentError, 'route_stops must be an Array or RouteStopCollection'
end
end
|