Skip to content

Commit

Permalink
Add groonga:sync task
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Mar 27, 2016
1 parent 1e026ac commit ea25f48
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/groonga/client/railtie.rb
Expand Up @@ -20,6 +20,10 @@ module Groonga
class Client
# @private
class Railtie < ::Rails::Railtie
rake_tasks do
load "groonga/client/railties/groonga.rake"
end

initializer "groonga-client.eager_load" do |app|
app.paths.add("app/searchers",
eager_load: true,
Expand Down
26 changes: 26 additions & 0 deletions lib/groonga/client/railties/groonga.rake
@@ -0,0 +1,26 @@
# -*- ruby -*-
#
# Copyright (C) 2016 Kouhei Sutou <kou@clear-code.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

namespace :groonga do
task :sync do
Rails.application.eager_load!
ObjectSpace.each_object(Class) do |klass|
klass.sync if klass < Groonga::Client::Searcher
end
end
end

0 comments on commit ea25f48

Please sign in to comment.