Class: Paresseux::Migration
- Inherits:
-
Object
- Object
- Paresseux::Migration
- Defined in:
- lib/paresseux/migration.rb
Instance Attribute Summary collapse
-
#current_version ⇒ Object
readonly
Returns the value of attribute current_version.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(model, version) ⇒ Migration
constructor
A new instance of Migration.
- #migrate ⇒ Object
- #migrate! ⇒ Object
Constructor Details
#initialize(model, version) ⇒ Migration
Returns a new instance of Migration.
6 7 8 |
# File 'lib/paresseux/migration.rb', line 6 def initialize(model, version) @model, @version, @current_version = model, version, model.paresseux_version end |
Instance Attribute Details
#current_version ⇒ Object (readonly)
Returns the value of attribute current_version.
4 5 6 |
# File 'lib/paresseux/migration.rb', line 4 def current_version @current_version end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
4 5 6 |
# File 'lib/paresseux/migration.rb', line 4 def model @model end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
4 5 6 |
# File 'lib/paresseux/migration.rb', line 4 def version @version end |
Instance Method Details
#migrate ⇒ Object
10 11 12 13 14 |
# File 'lib/paresseux/migration.rb', line 10 def migrate (current_version...version).each do |index| send("migration_#{index}_to_#{index + 1}") end end |
#migrate! ⇒ Object
16 17 18 19 |
# File 'lib/paresseux/migration.rb', line 16 def migrate! migrate model.save end |