Skip to content

Commit

Permalink
adding reload_database method to config class to clear the current da…
Browse files Browse the repository at this point in the history
…tabase from memory
  • Loading branch information
ryanb committed Jun 15, 2009
1 parent de23cc9 commit b2afadb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
* adding Xapit::Config#reload_database method

*0.2.1* (June 15th, 2009)

* including Xapit::Membership into ActiveRecord when using gem
Expand Down
4 changes: 2 additions & 2 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ You may want to trigger this via a cron job on a recurring schedule (i.e. every

There are two projects in development to help improve this reindexing.

http://github.com/ryanb/xapit-sync/tree/master
http://github.com/ryanb/xapit-server/tree/master
* http://github.com/ryanb/xapit-sync/tree/master
* http://github.com/ryanb/xapit-server/tree/master


== Search
Expand Down
6 changes: 6 additions & 0 deletions lib/xapit/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ def writable_database
# Removes the configured database file and clears the stored one in memory.
def remove_database # this can be a bit dangers, maybe do some checking here first?
FileUtils.rm_rf(path) if File.exist? path
reload_database
end

# Clear the current database from memory to fetch it again (upon request).
# Note: It is best to only use this on a readable database.
def reload_database
@database = nil
@writable_database = nil
end
Expand Down

0 comments on commit b2afadb

Please sign in to comment.