Class: ActiveRecord::ConnectionAdapters::PostgreSQL::Column

Inherits:
Column
  • Object
show all
Defined in:
lib/active_record/connection_adapters/postgresql/column.rb

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from Column

#collation, #comment, #default, #default_function, #name, #null, #sql_type_metadata

Instance Method Summary collapse

Methods inherited from Column

#bigint?, #has_default?, #human_name

Methods included from Deduplicable

#deduplicate

Constructor Details

#initialize(serial: nil) ⇒ Column

Returns a new instance of Column.



9
10
11
12
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 9

def initialize(*, serial: nil, **)
  super
  @serial = serial
end

Instance Method Details

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



37
38
39
40
41
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 37

def ==(other)
  other.is_a?(Column) &&
    super &&
    serial? == other.serial?
end

#arrayObject Also known as: array?



18
19
20
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 18

def array
  .sql_type.end_with?("[]")
end

#encode_with(coder) ⇒ Object



32
33
34
35
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 32

def encode_with(coder)
  coder["serial"] = @serial
  super
end

#hashObject



44
45
46
47
48
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 44

def hash
  Column.hash ^
    super.hash ^
    serial?.hash
end

#init_with(coder) ⇒ Object



27
28
29
30
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 27

def init_with(coder)
  @serial = coder["serial"]
  super
end

#serial?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 14

def serial?
  @serial
end

#sql_typeObject



23
24
25
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 23

def sql_type
  super.delete_suffix("[]")
end