Class: SpreeCmCommissioner::PricingModels::UpdateWithRuleGroups
- Inherits:
-
Object
- Object
- SpreeCmCommissioner::PricingModels::UpdateWithRuleGroups
- Includes:
- Spree::ServiceModule::Base
- Defined in:
- app/services/spree_cm_commissioner/pricing_models/update_with_rule_groups.rb
Instance Method Summary collapse
- #call(pricing_model:, params:, route: nil, origin_place_id: nil, destination_place_id: nil) ⇒ Object
Instance Method Details
#call(pricing_model:, params:, route: nil, origin_place_id: nil, destination_place_id: nil) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'app/services/spree_cm_commissioner/pricing_models/update_with_rule_groups.rb', line 6 def call(pricing_model:, params:, route: nil, origin_place_id: nil, destination_place_id: nil) ApplicationRecord.transaction do pricing_model.update!(model_params(params)) sync_rule_groups(pricing_model, params[:rule_groups]) update_route_assignment(pricing_model, route, origin_place_id, destination_place_id) if route.present? end success(pricing_model) rescue ActiveRecord::RecordInvalid => e failure(pricing_model, e.) end |