lib/earth/shipping/shipment_mode.rb in earth-0.12.4 vs lib/earth/shipping/shipment_mode.rb in earth-1.0.0

- old
+ new

@@ -1,13 +1,27 @@ +require 'earth/model' + +require 'earth/shipping/carrier_mode' + class ShipmentMode < ActiveRecord::Base + extend Earth::Model + + TABLE_STRUCTURE = <<-EOS + +CREATE TABLE shipment_modes + ( + name CHARACTER VARYING(255) NOT NULL PRIMARY KEY, + route_inefficiency_factor FLOAT, + transport_emission_factor FLOAT, + transport_emission_factor_units CHARACTER VARYING(255) + ); + +EOS + self.primary_key = "name" has_many :carrier_modes, :foreign_key => 'mode_name', :primary_key => 'name' - col :name - col :route_inefficiency_factor, :type => :float - col :transport_emission_factor, :type => :float - col :transport_emission_factor_units # verify "Route inefficiency factor should be one or more" do # ShipmentMode.all.each do |mode| # unless mode.route_inefficiency_factor >= 1.0 # raise "Invalid route inefficiency factor for ShipmentMode #{mode.name}: #{mode.route_inefficiency_factor} (should be >= 1.0)"