Class: CouchbaseOrm::IndexMigration::Operations::BuildIndexes
- Inherits:
-
Object
- Object
- CouchbaseOrm::IndexMigration::Operations::BuildIndexes
- Defined in:
- lib/couchbase-orm/index_migration/operations.rb
Instance Attribute Summary collapse
-
#index_names ⇒ Object
readonly
Returns the value of attribute index_names.
-
#wait ⇒ Object
readonly
Returns the value of attribute wait.
Instance Method Summary collapse
- #execute(migration) ⇒ Object
-
#initialize(index_names, wait: false) ⇒ BuildIndexes
constructor
A new instance of BuildIndexes.
- #inverse ⇒ Object
Constructor Details
#initialize(index_names, wait: false) ⇒ BuildIndexes
Returns a new instance of BuildIndexes.
25 26 27 28 29 |
# File 'lib/couchbase-orm/index_migration/operations.rb', line 25 def initialize(index_names, wait: false) @index_names = Array(index_names).flatten @wait = wait raise ArgumentError.new('At least one index name is required') if @index_names.empty? end |
Instance Attribute Details
#index_names ⇒ Object (readonly)
Returns the value of attribute index_names.
23 24 25 |
# File 'lib/couchbase-orm/index_migration/operations.rb', line 23 def index_names @index_names end |
#wait ⇒ Object (readonly)
Returns the value of attribute wait.
23 24 25 |
# File 'lib/couchbase-orm/index_migration/operations.rb', line 23 def wait @wait end |
Instance Method Details
#execute(migration) ⇒ Object
31 32 33 34 |
# File 'lib/couchbase-orm/index_migration/operations.rb', line 31 def execute(migration) migration.execute_query(migration.query_builder.build_indexes(index_names)) migration.wait_for_indexes_online(index_names) if wait end |
#inverse ⇒ Object
36 37 38 |
# File 'lib/couchbase-orm/index_migration/operations.rb', line 36 def inverse raise IrreversibleMigration.new('build_indexes is not reversible. Define down explicitly.') end |