module ValidatesTimeliness::Extensions::TimelinessDateTimeSelect

Constants

POSITION

Attributes

html_options[RW]

Intercepts the date and time select helpers to reuse the values from the params rather than the parsed value. This allows invalid date/time values to be redisplayed instead of blanks to aid correction by the user. It's a minor usability improvement which is rarely an issue for the user.

method_name[RW]

Intercepts the date and time select helpers to reuse the values from the params rather than the parsed value. This allows invalid date/time values to be redisplayed instead of blanks to aid correction by the user. It's a minor usability improvement which is rarely an issue for the user.

object_name[RW]

Intercepts the date and time select helpers to reuse the values from the params rather than the parsed value. This allows invalid date/time values to be redisplayed instead of blanks to aid correction by the user. It's a minor usability improvement which is rarely an issue for the user.

options[RW]

Intercepts the date and time select helpers to reuse the values from the params rather than the parsed value. This allows invalid date/time values to be redisplayed instead of blanks to aid correction by the user. It's a minor usability improvement which is rarely an issue for the user.

template_object[RW]

Intercepts the date and time select helpers to reuse the values from the params rather than the parsed value. This allows invalid date/time values to be redisplayed instead of blanks to aid correction by the user. It's a minor usability improvement which is rarely an issue for the user.

Public Instance Methods

value(*object) click to toggle source

Splat args to support Rails 5.0 which expects object, and 5.2 which doesn't

Calls superclass method
# File lib/validates_timeliness/extensions/date_time_select.rb, line 34
def value(*object)
  return super unless @template_object.params[@object_name]

  pairs = @template_object.params[@object_name].select {|k,v| k =~ /^#{@method_name}\(/ }
  return super if pairs.empty?

  values = {}
  pairs.each_pair do |key, value|
    position = key[/\((\d+)\w+\)/, 1]
    values[POSITION.key(position.to_i)] = value.to_i
  end

  DateTimeValue.new(values)
end