Sha256: e81177b09d2c7051ecb0c368b908e5e7458baa2fcd542314c2318c44e6c56bf4

Contents?: true

Size: 753 Bytes

Versions: 3

Compression:

Stored size: 753 Bytes

Contents

class Shoppe::DeliveryServicePrice < ActiveRecord::Base

  # Set the table name
  self.table_name = 'shoppe_delivery_service_prices'
  
  # Tax rates are associated with countries
  include Shoppe::AssociatedCountries
  
  # Relationships
  belongs_to :delivery_service, :class_name => 'Shoppe::DeliveryService'
  belongs_to :tax_rate, :class_name => "Shoppe::TaxRate"
  
  # Validations
  validates :price, :numericality => true
  validates :cost_price, :numericality => true, :allow_blank => true
  validates :min_weight, :numericality => true
  validates :max_weight, :numericality => true
  
  # Scopes
  scope :ordered, -> { order('price asc')}
  scope :for_weight, -> weight { where("min_weight <= ? AND max_weight >= ?", weight, weight) }
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
shoppe-0.0.14 app/models/shoppe/delivery_service_price.rb
shoppe-0.0.13 app/models/shoppe/delivery_service_price.rb
shoppe-0.0.12 app/models/shoppe/delivery_service_price.rb