[Groonga-commit] ranguba/epub-searcher at 8958ba2 [master] Extract db access to a method

Back to archive index

KITAITI Makoto null+****@clear*****
Tue Jan 13 20:27:20 JST 2015


KITAITI Makoto	2015-01-13 20:27:20 +0900 (Tue, 13 Jan 2015)

  New Revision: 8958ba2f9398e53e898277a592c62fba5a9c785b
  https://github.com/ranguba/epub-searcher/commit/8958ba2f9398e53e898277a592c62fba5a9c785b

  Message:
    Extract db access to a method

  Modified files:
    app/app.rb

  Modified: app/app.rb (+4 -3)
===================================================================
--- app/app.rb    2015-01-13 20:24:13 +0900 (75a7fae)
+++ app/app.rb    2015-01-13 20:27:20 +0900 (6117552)
@@ -59,7 +59,6 @@ module EPUBSearcher
     #
 
     def search_from_groonga(query_words)
-      db = RemoteDatabase.new(default_db_options)
       begin
         db.select(
           :table => :Books,
@@ -73,7 +72,6 @@ module EPUBSearcher
     end
 
     def books_from_groonga
-      db = RemoteDatabase.new(default_db_options)
       begin
         db.select(
           :table => :Books,
@@ -85,7 +83,6 @@ module EPUBSearcher
     end
 
     def delete_from_groonga(id)
-      db = RemoteDatabase.new(default_db_options)
       begin
         params = {
           :table => :Books,
@@ -98,6 +95,10 @@ module EPUBSearcher
     end
 
     private
+    def db
+      @db ||= RemoteDatabase.new(default_db_options)
+    end
+
     def default_db_options
       {
         :protocol => :http,
-------------- next part --------------
HTML����������������������������...
下载 



More information about the Groonga-commit mailing list
Back to archive index