Class: SpreeCmCommissioner::PricingModels::CreateWithRuleGroups
- Inherits:
-
Object
- Object
- SpreeCmCommissioner::PricingModels::CreateWithRuleGroups
- Includes:
- Spree::ServiceModule::Base
- Defined in:
- app/services/spree_cm_commissioner/pricing_models/create_with_rule_groups.rb
Instance Method Summary collapse
-
#call(vendor:, params:, route: nil, trip: nil, origin_place_id: nil, destination_place_id: nil) ⇒ Object
rubocop:disable Metrics/ParameterLists.
Instance Method Details
#call(vendor:, params:, route: nil, trip: nil, origin_place_id: nil, destination_place_id: nil) ⇒ Object
rubocop:disable Metrics/ParameterLists
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/services/spree_cm_commissioner/pricing_models/create_with_rule_groups.rb', line 6 def call(vendor:, params:, route: nil, trip: nil, origin_place_id: nil, destination_place_id: nil) # rubocop:disable Metrics/ParameterLists pricing_model = vendor.pricing_models.new(model_params(params)) ApplicationRecord.transaction do pricing_model.save! build_rule_groups(pricing_model, params[:rule_groups]) create_route_assignment(pricing_model, route, trip, origin_place_id, destination_place_id) if route.present? end success(pricing_model) rescue ActiveRecord::RecordInvalid => e failure(pricing_model, e.) end |