Class: TableCopy::PG::Index
- Inherits:
-
Object
- Object
- TableCopy::PG::Index
- Defined in:
- lib/table_copy/pg/index.rb
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#table ⇒ Object
readonly
Returns the value of attribute table.
Instance Method Summary collapse
- #create ⇒ Object
- #drop ⇒ Object
-
#initialize(table, name, columns) ⇒ Index
constructor
A new instance of Index.
Constructor Details
#initialize(table, name, columns) ⇒ Index
Returns a new instance of Index.
6 7 8 9 10 |
# File 'lib/table_copy/pg/index.rb', line 6 def initialize(table, name, columns) @table = table @name = name @columns = columns end |
Instance Attribute Details
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
4 5 6 |
# File 'lib/table_copy/pg/index.rb', line 4 def columns @columns end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/table_copy/pg/index.rb', line 4 def name @name end |
#table ⇒ Object (readonly)
Returns the value of attribute table.
4 5 6 |
# File 'lib/table_copy/pg/index.rb', line 4 def table @table end |
Instance Method Details
#create ⇒ Object
12 13 14 |
# File 'lib/table_copy/pg/index.rb', line 12 def create @create ||= "create index on #{table} using btree (#{columns.join(', ')})" end |
#drop ⇒ Object
16 17 18 |
# File 'lib/table_copy/pg/index.rb', line 16 def drop @drop ||= "drop index if exists #{name}" end |