Sha256: 47583186c2fa572d6ec4d12b55734e2df278fe2bff2b3e58c5f6ba302ef7752b

Contents?: true

Size: 835 Bytes

Versions: 36

Compression:

Stored size: 835 Bytes

Contents

# frozen_string_literal: true

module ActiveRecord
  module ConnectionAdapters
    module CipherStashPG
      module OID # :nodoc:
        class Date < Type::Date # :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

36 entries across 32 versions & 1 rubygems

Version Path
activerecord-cipherstash-pg-adapter-0.8.5 lib/active_record/connection_adapters/7.1/cipherstash_pg/oid/date.rb
activerecord-cipherstash-pg-adapter-0.8.5 lib/active_record/connection_adapters/7.0/cipherstash_pg/oid/date.rb
activerecord-cipherstash-pg-adapter-0.8.4 lib/active_record/connection_adapters/7.1/cipherstash_pg/oid/date.rb
activerecord-cipherstash-pg-adapter-0.8.4 lib/active_record/connection_adapters/7.0/cipherstash_pg/oid/date.rb
activerecord-cipherstash-pg-adapter-0.8.3 lib/active_record/connection_adapters/7.0/cipherstash_pg/oid/date.rb
activerecord-cipherstash-pg-adapter-0.8.3 lib/active_record/connection_adapters/7.1/cipherstash_pg/oid/date.rb
activerecord-cipherstash-pg-adapter-0.8.2 lib/active_record/connection_adapters/7.0/cipherstash_pg/oid/date.rb
activerecord-cipherstash-pg-adapter-0.8.2 lib/active_record/connection_adapters/7.1/cipherstash_pg/oid/date.rb
activerecord-cipherstash-pg-adapter-0.8.1 lib/active_record/connection_adapters/7.0/cipherstash_pg/oid/date.rb
activerecord-cipherstash-pg-adapter-0.8.0 lib/active_record/connection_adapters/7.0/cipherstash_pg/oid/date.rb
activerecord-cipherstash-pg-adapter-0.7.19 lib/active_record/connection_adapters/7.0/cipherstash_pg/oid/date.rb
activerecord-cipherstash-pg-adapter-0.7.18 lib/active_record/connection_adapters/7.0/cipherstash_pg/oid/date.rb
activerecord-cipherstash-pg-adapter-0.7.17 lib/active_record/connection_adapters/7.0/cipherstash_pg/oid/date.rb
activerecord-cipherstash-pg-adapter-0.7.16 lib/active_record/connection_adapters/7.0/cipherstash_pg/oid/date.rb
activerecord-cipherstash-pg-adapter-0.7.15 lib/active_record/connection_adapters/7.0/cipherstash_pg/oid/date.rb
activerecord-cipherstash-pg-adapter-0.7.14 lib/active_record/connection_adapters/7.0/cipherstash_pg/oid/date.rb
activerecord-cipherstash-pg-adapter-0.7.12 lib/active_record/connection_adapters/7.0/cipherstash_pg/oid/date.rb
activerecord-cipherstash-pg-adapter-0.7.11 lib/active_record/connection_adapters/7.0/cipherstash_pg/oid/date.rb
activerecord-cipherstash-pg-adapter-0.7.10 lib/active_record/connection_adapters/7.0/cipherstash_pg/oid/date.rb
activerecord-cipherstash-pg-adapter-0.7.9 lib/active_record/connection_adapters/7.0/cipherstash_pg/oid/date.rb