Sha256: 164c0b4135689b42ad580f13bfe4ee2b9efa7177f4f32d01291e9deac2bc90b8

Contents?: true

Size: 544 Bytes

Versions: 5

Compression:

Stored size: 544 Bytes

Contents

module Mks
  module Rate
    class ServiceBundleService
      def add_services(bundle, ids)
        selected_services = Mks::Rate::ChargeableService.where(id: ids)

        ServiceBundle.transaction do
          new_services = selected_services - bundle.chargeable_services
          removable_services = bundle.chargeable_services - selected_services
          bundle.chargeable_services.delete(removable_services)
          bundle.chargeable_services << new_services
          return true
        end
        false
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mks_rate-1.0.5 app/services/mks/rate/service_bundle_service.rb
mks_rate-1.0.4 app/services/mks/rate/service_bundle_service.rb
mks_rate-1.0.3 app/services/mks/rate/service_bundle_service.rb
mks_rate-1.0.2 app/services/mks/rate/service_bundle_service.rb
mks_rate-1.0.1 app/services/mks/rate/service_bundle_service.rb