Class: Stall::ShippingFeeCalculatorService
- Inherits:
-
BaseService
- Object
- BaseService
- Stall::ShippingFeeCalculatorService
- Defined in:
- app/services/stall/shipping_fee_calculator_service.rb
Instance Attribute Summary collapse
-
#cart ⇒ Object
readonly
Returns the value of attribute cart.
Instance Method Summary collapse
- #available? ⇒ Boolean
- #call ⇒ Object
-
#initialize(cart) ⇒ ShippingFeeCalculatorService
constructor
A new instance of ShippingFeeCalculatorService.
Constructor Details
#initialize(cart) ⇒ ShippingFeeCalculatorService
Returns a new instance of ShippingFeeCalculatorService.
5 6 7 |
# File 'app/services/stall/shipping_fee_calculator_service.rb', line 5 def initialize(cart) @cart = cart end |
Instance Attribute Details
#cart ⇒ Object (readonly)
Returns the value of attribute cart.
3 4 5 |
# File 'app/services/stall/shipping_fee_calculator_service.rb', line 3 def cart @cart end |
Instance Method Details
#available? ⇒ Boolean
15 16 17 18 19 |
# File 'app/services/stall/shipping_fee_calculator_service.rb', line 15 def available? cart.line_items.length > 0 && cart.try(:shipping_address) && cart.try(:shipment).try(:shipping_method) end |
#call ⇒ Object
9 10 11 12 13 |
# File 'app/services/stall/shipping_fee_calculator_service.rb', line 9 def call return reset_shipment_price unless available? update_price_for(cart.shipment, calculator) if calculator end |