Class: Rake::Migrations::Migrator

Inherits:
Object
  • Object
show all
Defined in:
lib/rake/migrations/migrator.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(task) ⇒ Migrator

Returns a new instance of Migrator.



30
31
32
# File 'lib/rake/migrations/migrator.rb', line 30

def initialize(task)
  @task = task
end

Instance Attribute Details

#taskObject (readonly)

Returns the value of attribute task.



28
29
30
# File 'lib/rake/migrations/migrator.rb', line 28

def task
  @task
end

Class Method Details

.configObject



20
21
22
# File 'lib/rake/migrations/migrator.rb', line 20

def self.config
  @config ||= Rake::Migrations::Configuration.load
end

.get_task_migrationsObject

tasks to run every time + tasks that haven’t been run yet



10
11
12
13
14
# File 'lib/rake/migrations/migrator.rb', line 10

def self.get_task_migrations
  config.tasks.select do |task|
    task.run_every_time? || manifest.tasks.exclude?(task)
  end
end

.invoke(task) ⇒ Object



24
25
26
# File 'lib/rake/migrations/migrator.rb', line 24

def self.invoke(task)
  new(task).invoke
end

.manifestObject



16
17
18
# File 'lib/rake/migrations/migrator.rb', line 16

def self.manifest
  @manifest ||= Rake::Migrations::Manifest.load
end

.run_task_migrationsObject



3
4
5
6
7
# File 'lib/rake/migrations/migrator.rb', line 3

def self.run_task_migrations
  get_task_migrations.each do |task|
    invoke task
  end
end

Instance Method Details

#invokeObject



34
35
36
37
38
# File 'lib/rake/migrations/migrator.rb', line 34

def invoke
  with_handler do
    Rake::Task[task.command].invoke
  end
end

#manifestObject



40
41
42
# File 'lib/rake/migrations/migrator.rb', line 40

def manifest
  self.class.manifest
end