Sha256: 45ffbd949200e2e8e760abce7434dadd71f55cf8ec341a19334e587b54142b2f

Contents?: true

Size: 799 Bytes

Versions: 1

Compression:

Stored size: 799 Bytes

Contents

module ActiveRecord
  module ConnectionAdapters
    class PostgreSQLTypeMetadata < DelegateClass(SqlTypeMetadata)
      attr_reader :oid, :fmod, :array

      def initialize(type_metadata, oid: nil, fmod: nil)
        super(type_metadata)
        @type_metadata = type_metadata
        @oid = oid
        @fmod = fmod
        @array = /\[\]$/.match?(type_metadata.sql_type)
      end

      def sql_type
        super.gsub(/\[\]$/, "".freeze)
      end

      def ==(other)
        other.is_a?(PostgreSQLTypeMetadata) &&
          attributes_for_hash == other.attributes_for_hash
      end
      alias eql? ==

      def hash
        attributes_for_hash.hash
      end

      protected

        def attributes_for_hash
          [self.class, @type_metadata, oid, fmod]
        end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activerecord-5.1.0.beta1 lib/active_record/connection_adapters/postgresql/type_metadata.rb