Fix issue#166 alias_method_chain not working in Rails 5
Changes include:
Use Module.prepend instead of alias_method_chain
Combined codes from DateTimeSelect and TimelinessDateTime into TimelinessDateTimeSelect
Modified initialize method as per latest method definition
Removed change method as I did not find it being used for the purpose. Do let me know if it is still needed.
Renamed value_with_timeliness to value and modified definition to use changes of Module.prepend
Now DateTime.new(), Time.utc() or any other similar method works differently
Either it does not accept invalid date parameters raising error as 'invalid date'
For example: DateTime.new(2018, 2, 31, 10, 16, 0) raises ArgumentError: invalid date
Or active_record internally converts date to next correct date
For example: 31st February is converted to 3rd March
Due to this changed behaviour, got to change the way value (datetime with errored date parameters) is passed
Also changed param.scan(/\((\d+)\w+\)/).first.first to prettier alternative param[/\((\d+)\w+\)/, 1]
@adzap Please review changes.
I am already using changes in my Rails 5.2.0 project.
As Travis CI is failing please let me know changes to make tests run for Rails 5
Fix issue#166 alias_method_chain not working in Rails 5
Changes include:
Module.prepend
instead ofalias_method_chain
DateTimeSelect
andTimelinessDateTime
intoTimelinessDateTimeSelect
initialize
method as per latest method definitionchange
method as I did not find it being used for the purpose. Do let me know if it is still needed.value_with_timeliness
tovalue
and modified definition to use changes ofModule.prepend
DateTime.new()
,Time.utc()
or any other similar method works differentlyDateTime.new(2018, 2, 31, 10, 16, 0)
raisesArgumentError: invalid date
31st February
is converted to3rd March
param.scan(/\((\d+)\w+\)/).first.first
to prettier alternativeparam[/\((\d+)\w+\)/, 1]