forked from nulldb/nulldb
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Actually works in a real world project.
* Updated documentation.
- Loading branch information
Avdi Grimm
committed
Feb 18, 2008
1 parent
a19a383
commit 2e46b54
Showing
6 changed files
with
151 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
# Nothing do to here... | ||
require 'active_record/connection_adapters/nulldb_adapter' | ||
|
||
::NullDB = ActiveRecord::ConnectionAdapters::NullDB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Sadly, we have to monkeypatch Rake because all of the Rails database tasks are | ||
# hardcoded for specific adapters, with no extension points (!) | ||
Rake::TaskManager.class_eval do | ||
def remove_task(task_name) | ||
@tasks.delete(task_name.to_s) | ||
end | ||
end | ||
|
||
def remove_task(task_name) | ||
Rake.application.remove_task(task_name) | ||
end | ||
|
||
def wrap_task(task_name, &wrapper) | ||
wrapped_task = Rake::Task[task_name] | ||
remove_task(Rake::Task.scope_name(Rake.application.current_scope, | ||
task_name)) | ||
task(task_name) do | ||
wrapper.call(wrapped_task) | ||
end | ||
end | ||
|
||
# For later exploration... | ||
# namespace :db do | ||
# namespace :test do | ||
# wrap_task :purge do |wrapped_task| | ||
# if ActiveRecord::Base.configurations["test"]["adapter"] == "nulldb" | ||
# # NO-OP | ||
# else | ||
# wrapped_task.invoke | ||
# end | ||
# end | ||
# end | ||
# end |