Sha256: 93b04bfed48f4897e6d9551b78cf4d465cd702e06e34a92460cee282f9a9f615

Contents?: true

Size: 979 Bytes

Versions: 7

Compression:

Stored size: 979 Bytes

Contents

require 'earth/model'
require 'falls_back_on'

require 'earth/shipping/carrier_mode'

class Carrier < ActiveRecord::Base
  extend Earth::Model

  TABLE_STRUCTURE = <<-EOS

CREATE TABLE carriers
  (
     name                            CHARACTER VARYING(255) NOT NULL PRIMARY KEY,
     full_name                       CHARACTER VARYING(255),
     package_volume                  FLOAT,
     route_inefficiency_factor       FLOAT,
     transport_emission_factor       FLOAT,
     transport_emission_factor_units CHARACTER VARYING(255),
     corporate_emission_factor       FLOAT,
     corporate_emission_factor_units CHARACTER VARYING(255)
  );

EOS

  self.primary_key = "name"
  
  has_many :carrier_modes, :foreign_key => 'carrier_name', :primary_key => 'name'
  
  # TODO calculate these
  falls_back_on :route_inefficiency_factor => 1.03,
                :transport_emission_factor => 0.0005266,
                :corporate_emission_factor => 0.221
  
  warn_unless_size 3
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
earth-1.2.1 lib/earth/shipping/carrier.rb
earth-1.1.2 lib/earth/shipping/carrier.rb
earth-1.1.1 lib/earth/shipping/carrier.rb
earth-1.1.0 lib/earth/shipping/carrier.rb
earth-1.0.3 lib/earth/shipping/carrier.rb
earth-1.0.2 lib/earth/shipping/carrier.rb
earth-1.0.1 lib/earth/shipping/carrier.rb