Class: ShippingMethod

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/shipping_method.rb

Instance Method Summary collapse

Instance Method Details

#available?(order) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
12
13
# File 'app/models/shipping_method.rb', line 9

def available?(order)
  calculator = shipping_calculator.constantize.new                               
  return true unless calculator.respond_to?(:available?)
  calculator.available?(order)    
end

#calculate_shipping(shipment) ⇒ Object



4
5
6
7
# File 'app/models/shipping_method.rb', line 4

def calculate_shipping(shipment)
  return 0 unless zone.include?(shipment.address)
  return shipping_calculator.constantize.new.send(:calculate_shipping, shipment)
end