Skip to content

Commit

Permalink
with_query to dry up Queryer::Client
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Rothstein committed Feb 16, 2010
1 parent 789ebba commit 08e7b88
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/queryer/client.rb
Expand Up @@ -8,18 +8,19 @@ def initialize(pool, queryer)
@queryer = queryer
end

def select(query_string)
def with_query(query_string)
with_connection(query_string) do |env|
env['nk.query'] = @queryer.build_query(env)
@queryer.select(env)
yield env
end
end

def select(query_string)
with_query(query_string) { |env| @queryer.select(env) }
end

def execute(query_string)
with_connection(query_string) do |env|
env['nk.query'] = @queryer.build_query(env)
@queryer.execute(env)
end
with_query(query_string) { |env| @queryer.execute(env) }
end

def transaction
Expand Down

0 comments on commit 08e7b88

Please sign in to comment.