Class: ActiveRecord::ConnectionAdapters::CipherStashPG::Column

Inherits:
ConnectionAdapters::Column
  • Object
show all
Defined in:
lib/active_record/connection_adapters/6.1/cipherstash_pg/column.rb,
lib/active_record/connection_adapters/7.0/cipherstash_pg/column.rb,
lib/active_record/connection_adapters/7.1/cipherstash_pg/column.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(serial: nil, generated: nil) ⇒ Column

Returns a new instance of Column.



11
12
13
14
# File 'lib/active_record/connection_adapters/6.1/cipherstash_pg/column.rb', line 11

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

Instance Method Details

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



39
40
41
42
43
# File 'lib/active_record/connection_adapters/6.1/cipherstash_pg/column.rb', line 39

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

#arrayObject Also known as: array?



20
21
22
# File 'lib/active_record/connection_adapters/6.1/cipherstash_pg/column.rb', line 20

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

#encode_with(coder) ⇒ Object



34
35
36
37
# File 'lib/active_record/connection_adapters/6.1/cipherstash_pg/column.rb', line 34

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

#enum?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/active_record/connection_adapters/7.0/cipherstash_pg/column.rb', line 35

def enum?
  type == :enum
end

#has_default?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/active_record/connection_adapters/7.0/cipherstash_pg/column.rb', line 26

def has_default?
  super && !virtual?
end

#hashObject



46
47
48
49
50
# File 'lib/active_record/connection_adapters/6.1/cipherstash_pg/column.rb', line 46

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

#init_with(coder) ⇒ Object



29
30
31
32
# File 'lib/active_record/connection_adapters/6.1/cipherstash_pg/column.rb', line 29

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

#serial?Boolean Also known as: auto_incremented_by_db?

Returns:

  • (Boolean)


16
17
18
# File 'lib/active_record/connection_adapters/6.1/cipherstash_pg/column.rb', line 16

def serial?
  @serial
end

#sql_typeObject



25
26
27
# File 'lib/active_record/connection_adapters/6.1/cipherstash_pg/column.rb', line 25

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

#virtual?Boolean

Returns:

  • (Boolean)


21
22
23
24
# File 'lib/active_record/connection_adapters/7.0/cipherstash_pg/column.rb', line 21

def virtual?
  # We assume every generated column is virtual, no matter the concrete type
  @generated.present?
end