mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-25 07:16:41 +00:00
renamed methods which have been moved out of AR and so dont need to be fully qualified
This commit is contained in:
parent
d71f581e10
commit
3ac65b507f
@ -24,13 +24,13 @@ ValidatesTimeliness::Formats.compile_format_expressions
|
|||||||
|
|
||||||
module ValidatesTimeliness
|
module ValidatesTimeliness
|
||||||
|
|
||||||
mattr_accessor :ignore_datetime_restriction_errors
|
mattr_accessor :ignore_restriction_errors
|
||||||
mattr_accessor :date_time_error_value_formats
|
mattr_accessor :error_value_formats
|
||||||
mattr_accessor :default_error_messages
|
mattr_accessor :default_error_messages
|
||||||
|
|
||||||
@@ignore_datetime_restriction_errors = false
|
@@ignore_restriction_errors = false
|
||||||
|
|
||||||
@@date_time_error_value_formats = {
|
@@error_value_formats = {
|
||||||
:time => '%H:%M:%S',
|
:time => '%H:%M:%S',
|
||||||
:date => '%Y-%m-%d',
|
:date => '%Y-%m-%d',
|
||||||
:datetime => '%Y-%m-%d %H:%M:%S'
|
:datetime => '%Y-%m-%d %H:%M:%S'
|
||||||
|
|||||||
@ -92,7 +92,7 @@ module Spec
|
|||||||
|
|
||||||
def format_value(value)
|
def format_value(value)
|
||||||
return value if value.is_a?(String)
|
return value if value.is_a?(String)
|
||||||
value.strftime(ValidatesTimeliness.date_time_error_value_formats[options[:type]])
|
value.strftime(ValidatesTimeliness.error_value_formats[options[:type]])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -36,7 +36,7 @@ module ValidatesTimeliness
|
|||||||
|
|
||||||
type_cast_method = self.class.restriction_type_cast_method(type)
|
type_cast_method = self.class.restriction_type_cast_method(type)
|
||||||
|
|
||||||
display = ValidatesTimeliness.date_time_error_value_formats[type]
|
display = ValidatesTimeliness.error_value_formats[type]
|
||||||
|
|
||||||
value = value.send(type_cast_method)
|
value = value.send(type_cast_method)
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ module ValidatesTimeliness
|
|||||||
add_error(record, attr_name, error_messages[option] % compare.strftime(display))
|
add_error(record, attr_name, error_messages[option] % compare.strftime(display))
|
||||||
end
|
end
|
||||||
rescue
|
rescue
|
||||||
unless ValidatesTimeliness.ignore_datetime_restriction_errors
|
unless ValidatesTimeliness.ignore_restriction_errors
|
||||||
add_error(record, attr_name, "restriction '#{option}' value was invalid")
|
add_error(record, attr_name, "restriction '#{option}' value was invalid")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -376,11 +376,11 @@ describe ValidatesTimeliness::ValidationMethods do
|
|||||||
end
|
end
|
||||||
|
|
||||||
before :all do
|
before :all do
|
||||||
ValidatesTimeliness.ignore_datetime_restriction_errors = true
|
ValidatesTimeliness.ignore_restriction_errors = true
|
||||||
end
|
end
|
||||||
|
|
||||||
after :all do
|
after :all do
|
||||||
ValidatesTimeliness.ignore_datetime_restriction_errors = false
|
ValidatesTimeliness.ignore_restriction_errors = false
|
||||||
end
|
end
|
||||||
|
|
||||||
before :each do
|
before :each do
|
||||||
@ -426,7 +426,7 @@ describe ValidatesTimeliness::ValidationMethods do
|
|||||||
|
|
||||||
describe "custom formats" do
|
describe "custom formats" do
|
||||||
before :all do
|
before :all do
|
||||||
ValidatesTimeliness.date_time_error_value_formats = {
|
ValidatesTimeliness.error_value_formats = {
|
||||||
:time => '%H:%M %p',
|
:time => '%H:%M %p',
|
||||||
:date => '%d-%m-%Y',
|
:date => '%d-%m-%Y',
|
||||||
:datetime => '%d-%m-%Y %H:%M %p'
|
:datetime => '%d-%m-%Y %H:%M %p'
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user