Class: Torque::PostgreSQL::Adapter::CompositeTypeDefinition
- Inherits:
-
ActiveRecord::ConnectionAdapters::PostgreSQL::TableDefinition
- Object
- ActiveRecord::ConnectionAdapters::PostgreSQL::TableDefinition
- Torque::PostgreSQL::Adapter::CompositeTypeDefinition
- 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
-
#changes ⇒ Object
readonly
Returns the value of attribute changes.
-
#removals ⇒ Object
readonly
Returns the value of attribute removals.
-
#renames ⇒ Object
readonly
Returns the value of attribute renames.
Instance Method Summary collapse
- #change(name, type, **options) ⇒ Object
-
#initialize(*args, **xargs) ⇒ CompositeTypeDefinition
constructor
A new instance of CompositeTypeDefinition.
- #remove(*names) ⇒ Object
- #rename(name, new_name) ⇒ Object
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
#changes ⇒ Object (readonly)
Returns the value of attribute changes.
75 76 77 |
# File 'lib/torque/postgresql/adapter/schema_definitions.rb', line 75 def changes @changes end |
#removals ⇒ Object (readonly)
Returns the value of attribute removals.
75 76 77 |
# File 'lib/torque/postgresql/adapter/schema_definitions.rb', line 75 def removals @removals end |
#renames ⇒ Object (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, **) @changes << new_column_definition(name, type, **) 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 |