Sha256: 9a1f4a424f3dd0d45cec45bd32f6ce72c0fb57632097399e3e397d9d129f6e88

Contents?: true

Size: 843 Bytes

Versions: 30

Compression:

Stored size: 843 Bytes

Contents

# frozen_string_literal: true

module ActiveRecord
  module ConnectionAdapters
    module CipherStashPG
      module OID # :nodoc:
        class DateTime < Type::DateTime # :nodoc:
          def cast_value(value)
            case value
            when "infinity" then ::Float::INFINITY
            when "-infinity" then -::Float::INFINITY
            when / BC$/
              value = value.sub(/^\d+/) { |year| format("%04d", -year.to_i + 1) }
              super(value.delete_suffix!(" BC"))
            else
              super
            end
          end

          def type_cast_for_schema(value)
            case value
            when ::Float::INFINITY then "::Float::INFINITY"
            when -::Float::INFINITY then "-::Float::INFINITY"
            else super
            end
          end
        end
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
activerecord-cipherstash-pg-adapter-0.8.5 lib/active_record/connection_adapters/6.1/cipherstash_pg/oid/date_time.rb
activerecord-cipherstash-pg-adapter-0.8.4 lib/active_record/connection_adapters/6.1/cipherstash_pg/oid/date_time.rb
activerecord-cipherstash-pg-adapter-0.8.3 lib/active_record/connection_adapters/6.1/cipherstash_pg/oid/date_time.rb
activerecord-cipherstash-pg-adapter-0.8.2 lib/active_record/connection_adapters/6.1/cipherstash_pg/oid/date_time.rb
activerecord-cipherstash-pg-adapter-0.8.1 lib/active_record/connection_adapters/6.1/cipherstash_pg/oid/date_time.rb
activerecord-cipherstash-pg-adapter-0.8.0 lib/active_record/connection_adapters/6.1/cipherstash_pg/oid/date_time.rb
activerecord-cipherstash-pg-adapter-0.7.19 lib/active_record/connection_adapters/6.1/cipherstash_pg/oid/date_time.rb
activerecord-cipherstash-pg-adapter-0.7.18 lib/active_record/connection_adapters/6.1/cipherstash_pg/oid/date_time.rb
activerecord-cipherstash-pg-adapter-0.7.17 lib/active_record/connection_adapters/6.1/cipherstash_pg/oid/date_time.rb
activerecord-cipherstash-pg-adapter-0.7.16 lib/active_record/connection_adapters/6.1/cipherstash_pg/oid/date_time.rb
activerecord-cipherstash-pg-adapter-0.7.15 lib/active_record/connection_adapters/6.1/cipherstash_pg/oid/date_time.rb
activerecord-cipherstash-pg-adapter-0.7.14 lib/active_record/connection_adapters/6.1/cipherstash_pg/oid/date_time.rb
activerecord-cipherstash-pg-adapter-0.7.12 lib/active_record/connection_adapters/6.1/cipherstash_pg/oid/date_time.rb
activerecord-cipherstash-pg-adapter-0.7.11 lib/active_record/connection_adapters/6.1/cipherstash_pg/oid/date_time.rb
activerecord-cipherstash-pg-adapter-0.7.10 lib/active_record/connection_adapters/6.1/cipherstash_pg/oid/date_time.rb
activerecord-cipherstash-pg-adapter-0.7.9 lib/active_record/connection_adapters/6.1/cipherstash_pg/oid/date_time.rb
activerecord-cipherstash-pg-adapter-0.7.8 lib/active_record/connection_adapters/6.1/cipherstash_pg/oid/date_time.rb
activerecord-cipherstash-pg-adapter-0.7.7 lib/active_record/connection_adapters/6.1/cipherstash_pg/oid/date_time.rb
activerecord-cipherstash-pg-adapter-0.7.6 lib/active_record/connection_adapters/6.1/cipherstash_pg/oid/date_time.rb
activerecord-cipherstash-pg-adapter-0.7.5 lib/active_record/connection_adapters/6.1/cipherstash_pg/oid/date_time.rb