Class: ActiveRecord::ConnectionAdapters::SqlTypeMetadata

Inherits:
Object
  • Object
show all
Includes:
Deduplicable
Defined in:
activerecord/lib/active_record/connection_adapters/sql_type_metadata.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Deduplicable

#deduplicate

Methods included from ActiveSupport::Concern

#append_features, #class_methods, extended, #included

Constructor Details

#initialize(sql_type: nil, type: nil, limit: nil, precision: nil, scale: nil) ⇒ SqlTypeMetadata

Returns a new instance of SqlTypeMetadata.



13
14
15
16
17
18
19
# File 'activerecord/lib/active_record/connection_adapters/sql_type_metadata.rb', line 13

def initialize(sql_type: nil, type: nil, limit: nil, precision: nil, scale: nil)
  @sql_type = sql_type
  @type = type
  @limit = limit
  @precision = precision
  @scale = scale
end

Instance Attribute Details

#limitObject (readonly)

Returns the value of attribute limit



11
12
13
# File 'activerecord/lib/active_record/connection_adapters/sql_type_metadata.rb', line 11

def limit
  @limit
end

#precisionObject (readonly)

Returns the value of attribute precision



11
12
13
# File 'activerecord/lib/active_record/connection_adapters/sql_type_metadata.rb', line 11

def precision
  @precision
end

#scaleObject (readonly)

Returns the value of attribute scale



11
12
13
# File 'activerecord/lib/active_record/connection_adapters/sql_type_metadata.rb', line 11

def scale
  @scale
end

#sql_typeObject (readonly)

Returns the value of attribute sql_type



11
12
13
# File 'activerecord/lib/active_record/connection_adapters/sql_type_metadata.rb', line 11

def sql_type
  @sql_type
end

#typeObject (readonly)

Returns the value of attribute type



11
12
13
# File 'activerecord/lib/active_record/connection_adapters/sql_type_metadata.rb', line 11

def type
  @type
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



21
22
23
24
25
26
27
28
# File 'activerecord/lib/active_record/connection_adapters/sql_type_metadata.rb', line 21

def ==(other)
  other.is_a?(SqlTypeMetadata) &&
    sql_type == other.sql_type &&
    type == other.type &&
    limit == other.limit &&
    precision == other.precision &&
    scale == other.scale
end

#hashObject



31
32
33
34
35
36
37
38
# File 'activerecord/lib/active_record/connection_adapters/sql_type_metadata.rb', line 31

def hash
  SqlTypeMetadata.hash ^
    sql_type.hash ^
    type.hash ^
    limit.hash ^
    precision.hash >> 1 ^
    scale.hash >> 2
end