aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/mysql/type_metadata.rb
blob: aa4d98e06bef8bd72c5bb1375530bc7a6b0a617d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# frozen_string_literal: true
module ActiveRecord
  module ConnectionAdapters
    module MySQL
      class TypeMetadata < DelegateClass(SqlTypeMetadata) # :nodoc:
        undef to_yaml if method_defined?(:to_yaml)

        attr_reader :extra

        def initialize(type_metadata, extra: "")
          super(type_metadata)
          @type_metadata = type_metadata
          @extra = extra
        end

        def ==(other)
          other.is_a?(MySQL::TypeMetadata) &&
            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, extra]
          end
      end
    end
  end
end