Class: Torque::PostgreSQL::Adapter::CompositeTypeDefinition

Inherits:
ActiveRecord::ConnectionAdapters::PostgreSQL::TableDefinition
  • Object
show all
Defined in:
lib/torque/postgresql/adapter/schema_definitions.rb,
sig/torque/postgresql/adapter/schema_definitions.rbs

Overview

Composite types are defined with the same DSL as tables, where declaring a column adds one, plus the operations that change_table provides

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args, **xargs) ⇒ CompositeTypeDefinition

Returns a new instance of CompositeTypeDefinition.

Parameters:

  • args (Object)
  • xargs (Object)


77
78
79
80
81
82
83
# File 'lib/torque/postgresql/adapter/schema_definitions.rb', line 77

def initialize(*args, **xargs)
  super

  @changes = []
  @removals = []
  @renames = []
end

Instance Attribute Details

#changes ⇒ Array[untyped] (readonly)

Returns the value of attribute changes.

Returns:

  • (Array[untyped])


75
76
77
# File 'lib/torque/postgresql/adapter/schema_definitions.rb', line 75

def changes
  @changes
end

#removals ⇒ Array[String] (readonly)

Returns the value of attribute removals.

Returns:

  • (Array[String])


75
76
77
# File 'lib/torque/postgresql/adapter/schema_definitions.rb', line 75

def removals
  @removals
end

#renames ⇒ Array[[String, String]] (readonly)

Returns the value of attribute renames.

Returns:

  • (Array[[String, String]])


75
76
77
# File 'lib/torque/postgresql/adapter/schema_definitions.rb', line 75

def renames
  @renames
end

Instance Method Details

#change(name, type, **options) ⇒ Array[untyped]

Parameters:

  • name (column_ref)
  • type (Symbol, String)
  • options (Object)

Returns:

  • (Array[untyped])


85
86
87
# File 'lib/torque/postgresql/adapter/schema_definitions.rb', line 85

def change(name, type, **options)
  @changes << new_column_definition(name, type, **options)
end

#remove(*names) ⇒ Array[String]

Parameters:

  • names (column_ref)

Returns:

  • (Array[String])


89
90
91
# File 'lib/torque/postgresql/adapter/schema_definitions.rb', line 89

def remove(*names)
  @removals.concat(names.map(&:to_s))
end

#rename(name, new_name) ⇒ Array[[String, String]]

Parameters:

  • name (column_ref)
  • new_name (column_ref)

Returns:

  • (Array[[String, String]])


93
94
95
# File 'lib/torque/postgresql/adapter/schema_definitions.rb', line 93

def rename(name, new_name)
  @renames << [name.to_s, new_name.to_s]
end