Class: Apartment::RakeTaskEnhancer
- Inherits:
-
Object
- Object
- Apartment::RakeTaskEnhancer
- Defined in:
- lib/apartment/tasks/enhancements.rb
Defined Under Namespace
Modules: TASKS
Class Method Summary collapse
- .enhance! ⇒ Object
- .enhance_after_task(task) ⇒ Object
- .enhance_before_task(task) ⇒ Object
- .inserted_task_name(task) ⇒ Object
- .should_enhance? ⇒ Boolean
Class Method Details
.enhance! ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/apartment/tasks/enhancements.rb', line 18 def enhance! return unless should_enhance? # insert task before TASKS::ENHANCE_BEFORE.each do |name| task = Rake::Task[name] enhance_before_task(task) end # insert task after TASKS::ENHANCE_AFTER.each do |name| task = Rake::Task[name] enhance_after_task(task) end end |
.enhance_after_task(task) ⇒ Object
42 43 44 45 46 |
# File 'lib/apartment/tasks/enhancements.rb', line 42 def enhance_after_task(task) task.enhance do Rake::Task[inserted_task_name(task)].invoke end end |
.enhance_before_task(task) ⇒ Object
38 39 40 |
# File 'lib/apartment/tasks/enhancements.rb', line 38 def enhance_before_task(task) task.enhance([inserted_task_name(task)]) end |
.inserted_task_name(task) ⇒ Object
48 49 50 |
# File 'lib/apartment/tasks/enhancements.rb', line 48 def inserted_task_name(task) task.name.sub(/db:/, 'apartment:') end |
.should_enhance? ⇒ Boolean
34 35 36 |
# File 'lib/apartment/tasks/enhancements.rb', line 34 def should_enhance? Apartment.db_migrate_tenants end |