Class: Apartment::RakeTaskEnhancer

Inherits:
Object
  • Object
show all
Defined in:
lib/apartment/tasks/enhancements.rb

Constant Summary collapse

TASKS =
%w(db:migrate db:rollback db:migrate:up db:migrate:down db:migrate:redo db:seed)

Class Method Summary collapse

Class Method Details

.enhance!Object


13
14
15
16
17
18
19
20
21
22
# File 'lib/apartment/tasks/enhancements.rb', line 13

def enhance!
  TASKS.each do |name|
    task = Rake::Task[name]
    task.enhance do
      if should_enhance?
        enhance_task(task)
      end
    end
  end
end

.enhance_task(task) ⇒ Object


28
29
30
# File 'lib/apartment/tasks/enhancements.rb', line 28

def enhance_task(task)
  Rake::Task[task.name.sub(/db:/, 'apartment:')].invoke
end

.should_enhance?Boolean

Returns:

  • (Boolean)

24
25
26
# File 'lib/apartment/tasks/enhancements.rb', line 24

def should_enhance?
  Apartment.db_migrate_tenants
end