Sha256: e72afa6a93e2c849930e35aab9624d628afb41ce4b4b5c29be6a640869562e03

Contents?: true

Size: 681 Bytes

Versions: 27

Compression:

Stored size: 681 Bytes

Contents

module RailsConnector

  # Adds support for string columns which contain ISO dates
  module DateAttribute #:nodoc: all
    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

27 entries across 27 versions & 2 rubygems

Version Path
infopark_fiona_connector-6.8.0.210.ed204b0 lib/rails_connector/date_attribute.rb
infopark_cloud_connector-6.8.0.210.ed204b0 lib/rails_connector/date_attribute.rb
infopark_fiona_connector-6.8.0.110.6570b45 lib/rails_connector/date_attribute.rb
infopark_cloud_connector-6.8.0.110.6570b45 lib/rails_connector/date_attribute.rb
infopark_fiona_connector-6.8.0.72.d18d096 lib/rails_connector/date_attribute.rb
infopark_cloud_connector-6.8.0.72.d18d096 lib/rails_connector/date_attribute.rb
infopark_fiona_connector-6.8.0.23.da7f96b lib/rails_connector/date_attribute.rb
infopark_cloud_connector-6.8.0.23.da7f96b lib/rails_connector/date_attribute.rb
infopark_fiona_connector-6.8.0.16.def5e85 lib/rails_connector/date_attribute.rb
infopark_cloud_connector-6.8.0.16.def5e85 lib/rails_connector/date_attribute.rb
infopark_cloud_connector-6.8.0.15.a24f5ff lib/rails_connector/date_attribute.rb
infopark_fiona_connector-6.8.0.beta.200.891.647580e lib/rails_connector/date_attribute.rb
infopark_cloud_connector-6.8.0.beta.200.891.647580e lib/rails_connector/date_attribute.rb
infopark_cloud_connector-6.8.0.beta.200.889.d503e42 lib/rails_connector/date_attribute.rb
infopark_cloud_connector-6.8.0.beta.200.883.f5f063b lib/rails_connector/date_attribute.rb
infopark_cloud_connector-6.8.0.beta.200.884.4bd86e6 lib/rails_connector/date_attribute.rb
infopark_cloud_connector-6.8.0.beta.200.869.9609b39 lib/rails_connector/date_attribute.rb
infopark_cloud_connector-6.8.0.beta.200.856.8c0fec5 lib/rails_connector/date_attribute.rb
infopark_cloud_connector-6.8.0.beta.200.809.bdfa8c3 lib/rails_connector/date_attribute.rb
infopark_cloud_connector-6.8.0.beta.200.785.05d4af9 lib/rails_connector/date_attribute.rb