Skip to content

Commit

Permalink
Merge pull request #168 from next-tms/format-package-new-dimensions
Browse files Browse the repository at this point in the history
Prevent prematurely processing `dimensions` on `Package.new`
  • Loading branch information
brodyhoskins authored Nov 17, 2024
2 parents bfb2663 + a275e93 commit 8872249
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions lib/freight_kit/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,14 @@ def initialize(total_grams_or_ounces, dimensions, packaging_type, options = {})
raise ArgumentError, 'Package#new: packaging_type is required' unless packaging_type
raise ArgumentError, 'Package#new: quantity is required' unless options[:quantity]

@dimensions = case dimensions
when Array
dimensions.map(&:presence)
when Hash
@dimensions = if dimensions.is_a?(Hash)
[
dimensions[:height].presence,
dimensions[:width].presence,
dimensions[:length].presence,
]
else
[nil, nil, nil]
dimensions
end

@description = options[:description]
Expand Down

0 comments on commit 8872249

Please sign in to comment.