evaluate_option_value specs

This commit is contained in:
Adam Meehan
2010-08-01 20:54:11 +10:00
parent 41c895c0d9
commit 12b59739ad
2 changed files with 69 additions and 2 deletions

View File

@@ -19,8 +19,23 @@ module ValidatesTimeliness
else
[0,0,0]
end
dummy_date = ValidatesTimeliness.dummy_date_for_time_type
Time.local(*(dummy_date + time))
Time.local(*(ValidatesTimeliness.dummy_date_for_time_type + time))
end
def evaluate_option_value(value, record)
case value
when Time, Date
value
when String
value.to_time(:local)
when Symbol
evaluate_option_value(record.send(value), record)
when Proc
result = value.arity > 0 ? value.call(record) : value.call
evaluate_option_value(result, record)
else
value
end
end
end