Class: SpreeCmCommissioner::AgencyUsers::Destroy
- Inherits:
-
Object
- Object
- SpreeCmCommissioner::AgencyUsers::Destroy
- Includes:
- Spree::ServiceModule::Base
- Defined in:
- app/services/spree_cm_commissioner/agency_users/destroy.rb
Instance Method Summary collapse
Instance Method Details
#call(agency_user:, roles:) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/services/spree_cm_commissioner/agency_users/destroy.rb', line 6 def call(agency_user:, roles:) ActiveRecord::Base.transaction do agency_user.user.role_users.where(role: roles).destroy_all agency_user.destroy raise ActiveRecord::Rollback if agency_user.deleted_at.blank? end return success(agency_user: agency_user) if agency_user.deleted_at.present? failure(agency_user, agency_user.errors..to_sentence.presence) end |