Module: TimeOfDayAttr::AttrWriterModule
- Defined in:
- lib/time_of_day_attr/active_record_extension.rb
Class Method Summary collapse
-
.new(attrs, options) ⇒ Object
rubocop:disable Metrics/MethodLength.
Class Method Details
.new(attrs, options) ⇒ Object
rubocop:disable Metrics/MethodLength
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/time_of_day_attr/active_record_extension.rb', line 22 def self.new(attrs, ) Module.new do attrs.each do |attr| define_method("#{attr}=") do |value| if value.is_a?(String) delocalized_value = TimeOfDayAttr.delocalize(value, ) super(delocalized_value) else super(value) end end end end end |