Updated Formula::calculate to use FormulaBuilder
This commit is contained in:
@@ -29,6 +29,24 @@ class Quantity < ActiveRecord::Base
|
||||
if new_record?
|
||||
self.domain ||= :diet
|
||||
end
|
||||
@formula = Formula.new(self.project, self.formula)
|
||||
end
|
||||
|
||||
def formula=(value)
|
||||
@formula = Formula.new(self.project, value)
|
||||
super(value)
|
||||
end
|
||||
|
||||
def formula_valid?
|
||||
@formula.valid?
|
||||
end
|
||||
|
||||
def formula_quantities
|
||||
@formula.get_quantities
|
||||
end
|
||||
|
||||
def calculate(inputs)
|
||||
@formula.calculate(inputs)
|
||||
end
|
||||
|
||||
def movable?(direction)
|
||||
@@ -47,14 +65,6 @@ class Quantity < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def formula_quantities
|
||||
Formula.new(self.project, self.formula).get_quantities
|
||||
end
|
||||
|
||||
def calculate(inputs)
|
||||
Formula.new(self.project, self.formula).calculate(inputs)
|
||||
end
|
||||
|
||||
def self.filter(project, filters)
|
||||
quantities = all
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
</td>
|
||||
<td class="domain"><%= q.domain %></td>
|
||||
<td class="description"><%= q.description %></td>
|
||||
<td class="formula"><%= checked_image q.formula.present? %></td>
|
||||
<td class="formula"><%= checked_image q.formula? %></td>
|
||||
<td class="action unwrappable">
|
||||
<%= link_to l(:button_edit), edit_quantity_path(q), {
|
||||
remote: true,
|
||||
|
||||
Reference in New Issue
Block a user