Navigation Menu

Skip to content

Commit

Permalink
Extract db access to a method
Browse files Browse the repository at this point in the history
  • Loading branch information
KitaitiMakoto committed Jan 13, 2015
1 parent 8c35613 commit 8958ba2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/app.rb
Expand Up @@ -59,7 +59,6 @@ class App < Padrino::Application
#

def search_from_groonga(query_words)
db = RemoteDatabase.new(default_db_options)
begin
db.select(
:table => :Books,
Expand All @@ -73,7 +72,6 @@ def search_from_groonga(query_words)
end

def books_from_groonga
db = RemoteDatabase.new(default_db_options)
begin
db.select(
:table => :Books,
Expand All @@ -85,7 +83,6 @@ def books_from_groonga
end

def delete_from_groonga(id)
db = RemoteDatabase.new(default_db_options)
begin
params = {
:table => :Books,
Expand All @@ -98,6 +95,10 @@ def delete_from_groonga(id)
end

private
def db
@db ||= RemoteDatabase.new(default_db_options)
end

def default_db_options
{
:protocol => :http,
Expand Down

0 comments on commit 8958ba2

Please sign in to comment.