Wrapped Deliverable.budget getter so it will return 0 if the budget is nil. #1708

This commit is contained in:
Eric Davis
2008-10-15 09:43:22 -07:00
parent 71060831fc
commit 52e80b4f56
2 changed files with 19 additions and 0 deletions

View File

@@ -123,6 +123,16 @@ class Deliverable < ActiveRecord::Base
end
end
# Wrap the budget getter so it returns 0 if budget is nil
def budget
raw_budget = read_attribute(:budget)
unless raw_budget.nil?
return raw_budget
else
return 0
end
end
# Amount of the budget remaining to be spent
def budget_remaining
return self.budget - self.spent