Sha256: 7a9731f3ca6c9a5f5bffaf60cacba69c1b4be13364e97f2d2a2d03f89e5a28d4

Contents?: true

Size: 668 Bytes

Versions: 48

Compression:

Stored size: 668 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).localtime
    rescue ArgumentError
      raise "The value is not a valid ISO date time: #{iso_date_time.inspect}"
    end
  end

end

Version data entries

48 entries across 48 versions & 2 rubygems

Version Path
infopark_fiona_connector-6.9.1.3.22208381 lib/rails_connector/date_attribute.rb
infopark_cloud_connector-6.9.1.3.22208381 lib/rails_connector/date_attribute.rb
infopark_fiona_connector-6.9.0.3.197272233 lib/rails_connector/date_attribute.rb
infopark_cloud_connector-6.9.0.3.197272233 lib/rails_connector/date_attribute.rb
infopark_fiona_connector-6.8.3.174.51542603 lib/rails_connector/date_attribute.rb
infopark_cloud_connector-6.8.3.174.51542603 lib/rails_connector/date_attribute.rb
infopark_fiona_connector-6.8.3.115.227021242 lib/rails_connector/date_attribute.rb
infopark_cloud_connector-6.8.3.115.227021242 lib/rails_connector/date_attribute.rb
infopark_fiona_connector-6.8.3.73.75172665 lib/rails_connector/date_attribute.rb
infopark_cloud_connector-6.8.3.73.75172665 lib/rails_connector/date_attribute.rb
infopark_fiona_connector-6.8.3.2.153416031 lib/rails_connector/date_attribute.rb
infopark_cloud_connector-6.8.3.2.153416031 lib/rails_connector/date_attribute.rb
infopark_fiona_connector-6.8.3.67.110847540 lib/rails_connector/date_attribute.rb
infopark_cloud_connector-6.8.3.67.110847540 lib/rails_connector/date_attribute.rb
infopark_fiona_connector-6.8.3.1.23895778 lib/rails_connector/date_attribute.rb
infopark_cloud_connector-6.8.3.1.23895778 lib/rails_connector/date_attribute.rb
infopark_fiona_connector-6.8.2.36.82613853 lib/rails_connector/date_attribute.rb
infopark_cloud_connector-6.8.2.36.82613853 lib/rails_connector/date_attribute.rb
infopark_fiona_connector-6.8.2.7.128454143 lib/rails_connector/date_attribute.rb
infopark_cloud_connector-6.8.2.7.128454143 lib/rails_connector/date_attribute.rb