Class: Bodega::ShippingMethod::Base
- Inherits:
-
Object
- Object
- Bodega::ShippingMethod::Base
- Extended by:
- Optional
- Includes:
- ActiveMerchant::Shipping
- Defined in:
- lib/bodega/shipping_method/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#order ⇒ Object
Returns the value of attribute order.
Instance Method Summary collapse
-
#initialize(order) ⇒ Base
constructor
A new instance of Base.
- #rates ⇒ Object
Methods included from Optional
Constructor Details
#initialize(order) ⇒ Base
Returns a new instance of Base.
11 12 13 |
# File 'lib/bodega/shipping_method/base.rb', line 11 def initialize(order) self.order = order end |
Instance Attribute Details
#order ⇒ Object
Returns the value of attribute order.
9 10 11 |
# File 'lib/bodega/shipping_method/base.rb', line 9 def order @order end |
Instance Method Details
#rates ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/bodega/shipping_method/base.rb', line 15 def rates return {} unless packages.any? @rates ||= {}.tap do |rates| response = client.find_rates(origin, destination, packages) response.rates.sort_by(&:price).each do |rate| rates[rate.service_code] = { name: rate.service_name, price: rate.price } end end end |