Sha256: 688db161bf08974425c2dff085e1ff0d124601eadb9357f029dc0cc818edad8b

Contents?: true

Size: 669 Bytes

Versions: 11

Compression:

Stored size: 669 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 %!
            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

11 entries across 11 versions & 1 rubygems

Version Path
infopark_fiona_connector-7.0.1.6.1.6.rc4 lib/rails_connector/date_attribute.rb
infopark_fiona_connector-7.0.1.6.1.6.rc3 lib/rails_connector/date_attribute.rb
infopark_fiona_connector-7.0.1.6.1.6.rc2 lib/rails_connector/date_attribute.rb
infopark_fiona_connector-7.0.1.6.1.6.rc1 lib/rails_connector/date_attribute.rb
infopark_fiona_connector-7.0.1.5.2.7.rc1 lib/rails_connector/date_attribute.rb
infopark_fiona_connector-7.0.1.5.2.4.rc2 lib/rails_connector/date_attribute.rb
infopark_fiona_connector-7.0.1.5.2.4.rc1 lib/rails_connector/date_attribute.rb
infopark_fiona_connector-7.0.1.5.2.3.rc8 lib/rails_connector/date_attribute.rb
infopark_fiona_connector-7.0.1.5.2.3.rc7 lib/rails_connector/date_attribute.rb
infopark_fiona_connector-7.0.1.5.2.3.rc6 lib/rails_connector/date_attribute.rb
infopark_fiona_connector-7.0.1.5.2.3.rc5 lib/rails_connector/date_attribute.rb