6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
# File 'lib/fuel_purchase/carbon_model.rb', line 6
def self.included(base)
base.extend ::Leap::Subject
base.decide :emission, :with => :characteristics do
committee :emission do
quorum 'from volume and emission factor', :needs => [:volume, :emission_factor] do |characteristics|
characteristics[:volume] * characteristics[:emission_factor]
end
quorum 'default' do
raise "The fuel purchase's default emission quorum should never be called"
end
end
committee :emission_factor do quorum 'from fuel type', :needs => :fuel_type do |characteristics|
characteristics[:fuel_type].emission_factor
end
quorum 'default' do
::FuelType.fallback.emission_factor
end
end
committee :volume do
quorum 'from cost and price', :needs => [:cost, :price] do |characteristics|
characteristics[:cost] / characteristics[:price]
end
quorum 'from fuel type', :needs => :fuel_type do |characteristics|
characteristics[:fuel_type].average_purchase_volume
end
quorum 'default' do FuelType.fallback.average_purchase_volume
end
end
committee :price do
quorum 'from fuel type', :needs => :fuel_type do |characteristics|
characteristics[:fuel_type].price
end
end
committee :petroleum_administration_for_defense_district do
quorum 'from state', :needs => :state do |characteristics|
characteristics[:state].petroleum_administration_for_defense_district
end
end
committee :state do
quorum 'from zip code', :needs => :zip_code do |characteristics|
characteristics[:zip_code].state
end
end
end
end
|