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, #prepend_features, #prepended

Constructor Details

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

Returns a new instance of SqlTypeMetadata.



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

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



9
10
11
# File 'activerecord/lib/active_record/connection_adapters/sql_type_metadata.rb', line 9

def limit
  @limit
end

#precisionObject (readonly)

Returns the value of attribute precision



9
10
11
# File 'activerecord/lib/active_record/connection_adapters/sql_type_metadata.rb', line 9

def precision
  @precision
end

#scaleObject (readonly)

Returns the value of attribute scale



9
10
11
# File 'activerecord/lib/active_record/connection_adapters/sql_type_metadata.rb', line 9

def scale
  @scale
end

#sql_typeObject (readonly)

Returns the value of attribute sql_type



9
10
11
# File 'activerecord/lib/active_record/connection_adapters/sql_type_metadata.rb', line 9

def sql_type
  @sql_type
end

#typeObject (readonly)

Returns the value of attribute type



9
10
11
# File 'activerecord/lib/active_record/connection_adapters/sql_type_metadata.rb', line 9

def type
  @type
end

Instance Method Details

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



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

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



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

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