Refactor: extract methods to a module and class helper, dollarized_attribute
This commit is contained in:
1 parent
83e3023d85
commit
56a38fbd93
5 files changed
+31
-31
No files matched your search
@@ -21,6 +21,8 @@ class Deliverable < ActiveRecord::Base
|
||||
validates_presence_of :manager
|
||||
|
||||
# Accessors
|
||||
include DollarizedAttribute
|
||||
dollarized_attribute :total
|
||||
|
||||
delegate :name, :to => :contract, :prefix => true, :allow_nil => true
|
||||
|
||||
@@ -53,14 +55,6 @@ class Deliverable < ActiveRecord::Base
|
||||
self.class.to_s.underscore
|
||||
end
|
||||
|
||||
def total=(v)
|
||||
if v.is_a? String
|
||||
write_attribute(:total, v.gsub(/[$ ,]/, ''))
|
||||
else
|
||||
write_attribute(:total, v)
|
||||
end
|
||||
end
|
||||
|
||||
def labor_budget_total(date=nil)
|
||||
labor_budgets.sum(:budget)
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user