Class: Migrate::Controller
- Inherits:
-
Object
- Object
- Migrate::Controller
- Defined in:
- lib/migrate/controller.rb
Instance Attribute Summary collapse
-
#migrations ⇒ Object
readonly
Returns the value of attribute migrations.
Instance Method Summary collapse
- #<<(migrations) ⇒ Object
-
#apply(migration) ⇒ Object
Apply the given migration.
-
#commit(migration) ⇒ Object
Persist that the migration was applied.
-
#initialize ⇒ Controller
constructor
A new instance of Controller.
Constructor Details
#initialize ⇒ Controller
Returns a new instance of Controller.
23 24 25 |
# File 'lib/migrate/controller.rb', line 23 def initialize @migrations = {} end |
Instance Attribute Details
#migrations ⇒ Object (readonly)
Returns the value of attribute migrations.
27 28 29 |
# File 'lib/migrate/controller.rb', line 27 def migrations @migrations end |
Instance Method Details
#<<(migrations) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/migrate/controller.rb', line 45 def << migrations migrations.each do |migration| apply(migration) do migration.call(self) end unless @migrations.include?(migration) end end |
#apply(migration) ⇒ Object
Apply the given migration.
30 31 32 33 34 35 36 37 38 |
# File 'lib/migrate/controller.rb', line 30 def apply(migration) start_time = Time.now yield duration = Time.now - start_time commit(migration) end |
#commit(migration) ⇒ Object
Persist that the migration was applied.
41 42 43 |
# File 'lib/migrate/controller.rb', line 41 def commit(migration) @migrations[migration.name] = migration end |