Class: MinceMigrator::Migrations::Runner
- Inherits:
-
Object
- Object
- MinceMigrator::Migrations::Runner
- Defined in:
- lib/mince_migrator/migrations/runner.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#validator ⇒ Object
readonly
Returns the value of attribute validator.
Instance Method Summary collapse
- #can_run_migration? ⇒ Boolean
-
#initialize(options) ⇒ Runner
constructor
A new instance of Runner.
- #migration ⇒ Object
- #reasons_for_failure ⇒ Object
- #run_migration ⇒ Object
Constructor Details
#initialize(options) ⇒ Runner
Returns a new instance of Runner.
10 11 12 13 14 15 16 17 18 |
# File 'lib/mince_migrator/migrations/runner.rb', line 10 def initialize() if [:migration] @migration = [:migration] @name = migration.name elsif [:name] @name = [:name] end @validator = RunnerValidator.new(migration) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/mince_migrator/migrations/runner.rb', line 8 def name @name end |
#validator ⇒ Object (readonly)
Returns the value of attribute validator.
8 9 10 |
# File 'lib/mince_migrator/migrations/runner.rb', line 8 def validator @validator end |
Instance Method Details
#can_run_migration? ⇒ Boolean
20 21 22 |
# File 'lib/mince_migrator/migrations/runner.rb', line 20 def can_run_migration? validator.call end |
#migration ⇒ Object
34 35 36 |
# File 'lib/mince_migrator/migrations/runner.rb', line 34 def migration @migration ||= Migration.find(name) end |
#reasons_for_failure ⇒ Object
30 31 32 |
# File 'lib/mince_migrator/migrations/runner.rb', line 30 def reasons_for_failure validator.errors.join(" ") end |
#run_migration ⇒ Object
24 25 26 27 28 |
# File 'lib/mince_migrator/migrations/runner.rb', line 24 def run_migration migration.run RanMigration.create(name: migration.name) true end |