Files
grecia/lib/active_model/dates.rb
Javi Martín 65c9786db7 Apply Layout/RedundantLineBreak rule to short lines
We're not adding the rule because it would apply the current line length
rule of 110 characters per line. We still haven't decided whether we'll
keep that rule or make lines shorter so they're easier to read,
particularly when vertically splitting the editor window.

So, for now, I'm applying the rule to lines which are about 90
characters long.
2021-09-03 11:49:53 +02:00

14 lines
380 B
Ruby

module ActiveModel::Dates
def parse_date(field, attrs)
year, month, day = attrs["#{field}(1i)"], attrs["#{field}(2i)"], attrs["#{field}(3i)"]
return nil unless day.present? && month.present? && year.present?
Date.new(year.to_i, month.to_i, day.to_i)
end
def remove_date(field, attrs)
attrs.except("#{field}(1i)", "#{field}(2i)", "#{field}(3i)")
end
end