Sha256: c91cf871a4185fb93d5db16b1a67d23abeabd3c2b4169e47cbddd5ffc47ab137

Contents?: true

Size: 1.51 KB

Versions: 1

Compression:

Stored size: 1.51 KB

Contents

# frozen_string_literal: true

module FriendlyShipping
  module Services
    class ShipEngineLTL
      class ShipmentOptions < FriendlyShipping::ShipmentOptions
        # @param structure_options [Array<StructureOptions>]
        # @param structure_options_class [Class]
        # @param kwargs [Hash]
        # @option kwargs [Array<PackageOptions>] :package_options
        # @option kwargs [Class] :package_options_class
        def initialize(
          structure_options: Set.new,
          structure_options_class: StructureOptions,
          **kwargs
        )
          @structure_options = structure_options
          @structure_options_class = structure_options_class
          super(**kwargs.reverse_merge(package_options_class: PackageOptions))
        end

        # @param [#id] structure
        # @return [StructureOptions]
        def options_for_structure(structure)
          structure_options.detect do |structure_option|
            structure_option.structure_id == structure.id
          end || structure_options_class.new(structure_id: nil)
        end

        private

        # @return [Array<StructureOptions>]
        attr_reader :structure_options

        # @return [Class]
        attr_reader :structure_options_class

        # @return [Array<PackageOptions>]
        # @deprecated Use {#structure_options} instead.
        def package_options
          warn "[DEPRECATION] `package_options` is deprecated.  Please use `structure_options` instead."
          @package_options
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
friendly_shipping-0.9.0 lib/friendly_shipping/services/ship_engine_ltl/shipment_options.rb