Class: FriendlyShipping::Services::ShipEngineLTL::ShipmentOptions

Inherits:
FriendlyShipping::ShipmentOptions show all
Defined in:
lib/friendly_shipping/services/ship_engine_ltl/shipment_options.rb

Instance Method Summary collapse

Methods inherited from FriendlyShipping::ShipmentOptions

#options_for_package

Constructor Details

#initialize(structure_options: Set.new, structure_options_class: StructureOptions, **kwargs) ⇒ ShipmentOptions

Returns a new instance of ShipmentOptions.

Parameters:

  • structure_options (Array<StructureOptions>) (defaults to: Set.new)
  • structure_options_class (Class) (defaults to: StructureOptions)
  • kwargs (Hash)

Options Hash (**kwargs):

  • :package_options (Array<PackageOptions>)
  • :package_options_class (Class)


12
13
14
15
16
17
18
19
20
# File 'lib/friendly_shipping/services/ship_engine_ltl/shipment_options.rb', line 12

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

Instance Method Details

#options_for_structure(structure) ⇒ StructureOptions

Parameters:

  • structure (#id)

Returns:



24
25
26
27
28
# File 'lib/friendly_shipping/services/ship_engine_ltl/shipment_options.rb', line 24

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