module SimpleMigrator::Migratable
Public Class Methods
included(base)
click to toggle source
# File lib/simple_migrator/migratable.rb, line 31 def self.included(base) base.extend(ClassMethods) end
Public Instance Methods
migrate!(_migrator = migrator)
click to toggle source
# File lib/simple_migrator/migratable.rb, line 3 def migrate!(_migrator = migrator) self.class.migrations.each do |migration| rebound_proc = rebind_proc(migration.proc) name = prefixed_migration_name(migration.name) _migrator.migrate(name, &rebound_proc) end end
migration_prefix()
click to toggle source
# File lib/simple_migrator/migratable.rb, line 19 def migration_prefix; end
migrator()
click to toggle source
# File lib/simple_migrator/migratable.rb, line 21 def migrator raise NoMigratorError, "`migrate!` called without a migrator.\nEither provide a migrator or define a `migrator` method" end
prefixed_migration_name(name)
click to toggle source
# File lib/simple_migrator/migratable.rb, line 11 def prefixed_migration_name(name) if migration_prefix [migration_prefix, name].join("_") else name end end
rebind_proc(proc)
click to toggle source
# File lib/simple_migrator/migratable.rb, line 25 def rebind_proc(proc) Proc.new do |db| instance_exec(db, &proc) end end