Sha256: 97fdd491350425acfa73e4739b471acfe9c9ed034cd14afa7e16c62afc094725

Contents?: true

Size: 1.54 KB

Versions: 3

Compression:

Stored size: 1.54 KB

Contents

require 'earth/locality'
class ComputationCarrierInstanceClass < ActiveRecord::Base
  self.primary_key = "name"
  
  belongs_to :computation_carrier, :foreign_key => 'computation_carrier_name'
  
  falls_back_on :name => 'fallback',
                :electricity_intensity => lambda { ComputationCarrierInstanceClass.find_by_name('Amazon m1.small').electricity_intensity },
                :electricity_intensity_units => lambda { ComputationCarrierInstanceClass.find_by_name('Amazon m1.small').electricity_intensity_units }
  
  col :name
  col :computation_carrier_name
  col :instance_class
  col :electricity_intensity, :type => :float
  col :electricity_intensity_units
  
  # FIXME TODO verify that computation carrier name appears in computation_carriers
  
  # verify "Electricity intensity should be more than zero" do
  #   ComputationCarrierInstanceClass.all.each do |instance_class|
  #     unless instance_class.electricity_intensity > 0
  #       raise "Invalid electricity intensity for ComputationCarrierInstanceClass #{instance_class.name}: #{instance_class.electricity_intensity} (should be > 0)"
  #     end
  #   end
  # end
  # 
  # verify "Electricity intensity units should be kilowatts" do
  #   ComputationCarrierInstanceClass.all.each do |instance_class|
  #     unless instance_class.electricity_intensity_units == 'kilowatts'
  #       raise "Invalid electricity intensity units for ComputationCarrierInstanceClass #{instance_class.name}: #{instance_class.electricity_intensity_units} (should be kilowatts)"
  #     end
  #   end
  # end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
earth-0.11.13 lib/earth/computation/computation_carrier_instance_class.rb
earth-0.11.12 lib/earth/computation/computation_carrier_instance_class.rb
earth-0.11.11 lib/earth/computation/computation_carrier_instance_class.rb