Sha256: 1db35e8854ec0be09ed701827763a90f14b8d1a462673bde2d1807485a3777c9

Contents?: true

Size: 1.53 KB

Versions: 3

Compression:

Stored size: 1.53 KB

Contents

require 'earth/locality'
class ComputationCarrierInstanceClass < ActiveRecord::Base
  set_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.10 lib/earth/computation/computation_carrier_instance_class.rb
earth-0.11.9 lib/earth/computation/computation_carrier_instance_class.rb
earth-0.11.8 lib/earth/computation/computation_carrier_instance_class.rb