Sha256: b949c3d019b80ab536d163c4f03298b5b8ae3b87853ed114b28a4aec944ba719
Contents?: true
Size: 672 Bytes
Versions: 1
Compression:
Stored size: 672 Bytes
Contents
module RailsConnector # Adds support for string columns which contain ISO dates module DateAttribute module ClassMethods def date_attribute(*names) names.each do |name| module_eval %Q! def #{name} DateAttribute.parse(#{name}_before_type_cast) unless #{name}_before_type_cast.nil? end ! end end end def self.included(base) base.extend(ClassMethods) end def self.parse(iso_date_time) Time.from_iso(iso_date_time).in_time_zone rescue ArgumentError raise "The value is not a valid ISO date time: #{iso_date_time.inspect}" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
infopark_fiona_connector-7.0.1.5.2.3.rc4 | lib/rails_connector/date_attribute.rb |