Changed the API so Rate#for will return a Rate object and Rate#amount_for

will return the rate amount.

  #1921
This commit is contained in:
Eric Davis
2009-01-20 15:26:01 -08:00
parent 8e89e69532
commit 8c5e58de04
3 changed files with 21 additions and 15 deletions

View File

@@ -37,6 +37,12 @@ class Rate < ActiveRecord::Base
rate = self.for_user_project_and_date(user, project, date)
# Check for a default (non-project) rate
rate = self.default_for_user_and_date(user, date) if rate.nil? && project
rate
end
# API to find the amount for a +user+ on a +project+ at a +date+
def self.amount_for(user, project = nil, date = Date.today.to_s)
rate = self.for(user, project, date)
return nil if rate.nil?
return rate.amount