Class: CouchbaseOrm::IndexMigration::Operations::BuildIndexes

Inherits:
Object
  • Object
show all
Defined in:
lib/couchbase-orm/index_migration/operations.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(index_names, wait: false) ⇒ BuildIndexes

Returns a new instance of BuildIndexes.

Raises:

  • (ArgumentError)


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_namesObject (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

#waitObject (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

#inverseObject



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