squirm 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/squirm/core.rb +9 -6
- data/lib/squirm/version.rb +1 -1
- metadata +5 -5
data/lib/squirm/core.rb
CHANGED
@@ -34,7 +34,8 @@ module Squirm
|
|
34
34
|
# Executes the query and passes the result to the block you specify.
|
35
35
|
def exec(*args, &block)
|
36
36
|
if current = Thread.current[:squirm_connection]
|
37
|
-
current.
|
37
|
+
conn = current.respond_to?(:raw_connection) ? current.raw_connection : current
|
38
|
+
conn.exec(*args, &block)
|
38
39
|
else
|
39
40
|
use {|conn| conn.exec(*args, &block)}
|
40
41
|
end
|
@@ -70,16 +71,18 @@ module Squirm
|
|
70
71
|
block_given? ? transaction {yield; rollback} : (raise Rollback)
|
71
72
|
end
|
72
73
|
|
73
|
-
#
|
74
|
-
#
|
75
|
-
|
76
|
-
|
74
|
+
# Uses a connection for all database access inside the given block. If no
|
75
|
+
# connection is given, then one will be checked out from the pool for use
|
76
|
+
# inside the block, and then checked back in when the method returns.
|
77
|
+
def use(conn = nil)
|
78
|
+
conn_given = !!conn
|
79
|
+
conn = conn_given ? conn : @pool.checkout
|
77
80
|
begin
|
78
81
|
Thread.current[:squirm_connection] = conn
|
79
82
|
yield conn.respond_to?(:raw_connection) ? conn.raw_connection : conn
|
80
83
|
ensure
|
81
84
|
Thread.current[:squirm_connection] = nil
|
82
|
-
@pool.checkin conn
|
85
|
+
@pool.checkin conn unless conn_given
|
83
86
|
end
|
84
87
|
end
|
85
88
|
|
data/lib/squirm/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: squirm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-12-22 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
16
|
-
requirement: &
|
16
|
+
requirement: &70112879161580 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '2.6'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70112879161580
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: pg
|
27
|
-
requirement: &
|
27
|
+
requirement: &70112879182280 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: 0.11.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70112879182280
|
36
36
|
description: ! '"Squirm is an anti-ORM for database-loving programmers"'
|
37
37
|
email:
|
38
38
|
- norman@njclarke.com
|