little cleanup and consistency

This commit is contained in:
Adam Meehan 2009-02-09 12:11:56 +11:00
parent 1001d29c01
commit 904c202fb4
3 changed files with 33 additions and 35 deletions

View File

@ -168,9 +168,9 @@ module ValidatesTimeliness
exp, processor = expression_set(type, string).find do |regexp, proc|
full = /\A#{regexp}\Z/ if strict
full ||= case type
when :datetime then /\A#{regexp}\Z/
when :date then /\A#{regexp}/
else /#{regexp}\Z/
when :time then /#{regexp}\Z/
when :datetime then /\A#{regexp}\Z/
end
matches = full.match(string.strip)
end

View File

@ -111,13 +111,11 @@ module ValidatesTimeliness
end
def error_messages
return @error_messages if defined?(@error_messages)
@error_messages = ValidatesTimeliness.default_error_messages.merge(custom_error_messages)
@error_messages ||= ValidatesTimeliness.default_error_messages.merge(custom_error_messages)
end
def custom_error_messages
return @custom_error_messages if defined?(@custom_error_messages)
@custom_error_messages = configuration.inject({}) {|msgs, (k, v)|
@custom_error_messages ||= configuration.inject({}) {|msgs, (k, v)|
if md = /(.*)_message$/.match(k.to_s)
msgs[md[1].to_sym] = v
end

View File

@ -35,7 +35,7 @@ describe ValidatesTimeliness::ActiveRecord::AttributeMethods do
@person.birth_time
end
it "should call rea_date_time_attribute when datetime attribute is retrieved" do
it "should call read_date_time_attribute when datetime attribute is retrieved" do
@person.should_receive(:read_date_time_attribute)
@person.birth_date_and_time = "2000-01-01 12:00"
@person.birth_date_and_time