Class: CouchbaseOrm::IndexMigrationContext
- Inherits:
-
Object
- Object
- CouchbaseOrm::IndexMigrationContext
- Defined in:
- lib/couchbase-orm/index_migration_context.rb
Defined Under Namespace
Classes: Migration
Instance Method Summary collapse
- #find(version) ⇒ Object
-
#initialize(path: CouchbaseOrm.config.index.migrations_path) ⇒ IndexMigrationContext
constructor
A new instance of IndexMigrationContext.
- #migrations ⇒ Object
- #pending_migrations(executed_versions) ⇒ Object
Constructor Details
#initialize(path: CouchbaseOrm.config.index.migrations_path) ⇒ IndexMigrationContext
Returns a new instance of IndexMigrationContext.
9 10 11 |
# File 'lib/couchbase-orm/index_migration_context.rb', line 9 def initialize(path: CouchbaseOrm.config.index.migrations_path) @path = path end |
Instance Method Details
#find(version) ⇒ Object
33 34 35 |
# File 'lib/couchbase-orm/index_migration_context.rb', line 33 def find(version) migrations.find { |migration| migration.version == version.to_s } end |
#migrations ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/couchbase-orm/index_migration_context.rb', line 13 def migrations migration_files.map do |file| version, underscored_name = parse_file_name(file) require File.(file) class_name = underscored_name.camelize Migration.new( version: version, name: class_name, klass: Object.const_get(class_name), path: file ) end end |
#pending_migrations(executed_versions) ⇒ Object
28 29 30 31 |
# File 'lib/couchbase-orm/index_migration_context.rb', line 28 def pending_migrations(executed_versions) executed_set = Array(executed_versions).map(&:to_s) migrations.reject { |migration| executed_set.include?(migration.version) } end |