Module: Mongoid::LazyMigration::ClassMethods

Defined in:
lib/mongoid/lazy_migration.rb

Instance Method Summary collapse

Instance Method Details

#migration(options = {}, &block) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/mongoid/lazy_migration.rb', line 21

def migration(options = {}, &block)
  include Mongoid::LazyMigration::Document

  field :migration_state, :type => Symbol, :default => :pending
  after_initialize :ensure_migration, :unless => proc { @migrating }

  cattr_accessor :migrate_block, :lock_migration
  self.migrate_block = block
  self.lock_migration = options[:lock]

  Mongoid::LazyMigration.models_to_migrate << self
end