Method: ActiveShipping::RateEstimate#add

Defined in:
lib/active_shipping/rate_estimate.rb

#add(package, rate = nil) ⇒ self

Adds a package to this rate estimate

Parameters:

  • package (ActiveShipping::Package)

    The package to add.

  • rate (#cents, Float, String, nil) (defaults to: nil)

    The rate for this package. This is only required if there is no total price for this shipment

Returns:

  • (self)

Raises:

  • (ArgumentError)


114
115
116
117
118
119
# File 'lib/active_shipping/rate_estimate.rb', line 114

def add(package, rate = nil)
  cents = Package.cents_from(rate)
  raise ArgumentError.new("New packages must have valid rate information since this RateEstimate has no total_price set.") if cents.nil? and total_price.nil?
  @package_rates << {:package => package, :rate => cents}
  self
end