mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-23 06:16:44 +00:00
added enable method for multiparameter attribute handling of datetime which is enabled by default but will be off in version2
renamed enable action view extension method and enable both extensions in the one method as they are needed together
This commit is contained in:
parent
1dbac5190b
commit
c3f3edf324
@ -21,6 +21,11 @@ module ValidatesTimeliness
|
||||
|
||||
class << self
|
||||
|
||||
def enable_datetime_select_extension!
|
||||
enable_datetime_select_invalid_value_extension!
|
||||
enable_multiparameter_attributes_extension!
|
||||
end
|
||||
|
||||
def load_error_messages
|
||||
if defined?(I18n)
|
||||
I18n.load_path += [ LOCALE_PATH ]
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
module ValidatesTimeliness
|
||||
|
||||
def self.enable_datetime_select_extension!
|
||||
def self.enable_datetime_select_invalid_value_extension!
|
||||
::ActionView::Helpers::InstanceTag.send(:include, ValidatesTimeliness::ActionView::InstanceTag)
|
||||
end
|
||||
|
||||
|
||||
@ -1,6 +1,10 @@
|
||||
module ValidatesTimeliness
|
||||
module ActiveRecord
|
||||
|
||||
def self.enable_multiparameter_attributes_extension!
|
||||
::ActiveRecord::Base.send(:include, ValidatesTimeliness::ActiveRecord::MultiparameterAttributes)
|
||||
end
|
||||
|
||||
module ActiveRecord
|
||||
module MultiparameterAttributes
|
||||
|
||||
def self.included(base)
|
||||
@ -38,13 +42,13 @@ module ValidatesTimeliness
|
||||
values = values.map(&:to_s)
|
||||
|
||||
case type
|
||||
when :date
|
||||
extract_date_from_multiparameter_attributes(values)
|
||||
when :time
|
||||
extract_time_from_multiparameter_attributes(values)
|
||||
when :datetime
|
||||
date_values, time_values = values.slice!(0, 3), values
|
||||
extract_date_from_multiparameter_attributes(date_values) + " " + extract_time_from_multiparameter_attributes(time_values)
|
||||
when :date
|
||||
extract_date_from_multiparameter_attributes(values)
|
||||
when :time
|
||||
extract_time_from_multiparameter_attributes(values)
|
||||
when :datetime
|
||||
date_values, time_values = values.slice!(0, 3), values
|
||||
extract_date_from_multiparameter_attributes(date_values) + " " + extract_time_from_multiparameter_attributes(time_values)
|
||||
end
|
||||
end
|
||||
|
||||
@ -60,5 +64,3 @@ module ValidatesTimeliness
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
ActiveRecord::Base.send(:include, ValidatesTimeliness::ActiveRecord::MultiparameterAttributes)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user