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

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

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.



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

#changesObject (readonly)

Returns the value of attribute changes.



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

def changes
  @changes
end

#removalsObject (readonly)

Returns the value of attribute removals.



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

def removals
  @removals
end

#renamesObject (readonly)

Returns the value of attribute renames.



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

def renames
  @renames
end

Instance Method Details

#change(name, type, **options) ⇒ Object



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) ⇒ Object



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) ⇒ Object



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