Sha256: 65a8cf581c52637584685026d51619d12a2628b5535618da199621b0d70d9b22

Contents?: true

Size: 893 Bytes

Versions: 14

Compression:

Stored size: 893 Bytes

Contents

# Require this file to append Penthouse rake tasks to ActiveRecord db rake tasks
# Enabled by default in the initializer

# shamelessly copied & adjusted from Apartment
# @see https://github.com/influitive/apartment/blob/development/lib/apartment/tasks/enhancements.rb

module Penthouse
  class RakeTaskEnhancer
    TASKS = %w(db:migrate db:rollback db:migrate:up db:migrate:down db:migrate:redo db:seed)

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

      def should_enhance?
        Penthouse.configuration.migrate_tenants?
      end

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

  end
end

Penthouse::RakeTaskEnhancer.enhance!

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
penthouse-0.8.0 lib/penthouse/tasks/enhancements.rb
penthouse-0.7.5 lib/penthouse/tasks/enhancements.rb
penthouse-0.7.4 lib/penthouse/tasks/enhancements.rb
penthouse-0.7.3 lib/penthouse/tasks/enhancements.rb
penthouse-0.7.2 lib/penthouse/tasks/enhancements.rb
penthouse-0.7.1 lib/penthouse/tasks/enhancements.rb
penthouse-0.7.0 lib/penthouse/tasks/enhancements.rb
penthouse-0.6.0 lib/penthouse/tasks/enhancements.rb
penthouse-0.5.0 lib/penthouse/tasks/enhancements.rb
penthouse-0.4.2 lib/penthouse/tasks/enhancements.rb
penthouse-0.4.1 lib/penthouse/tasks/enhancements.rb
penthouse-0.4.0 lib/penthouse/tasks/enhancements.rb
penthouse-0.3.0 lib/penthouse/tasks/enhancements.rb
penthouse-0.2.0 lib/penthouse/tasks/enhancements.rb