hedgerow 0.1.4 → 0.1.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 02eda5d2e58b0135bfbc69e17d21821ae79bccf1
4
- data.tar.gz: ec2f583e42675bff31e4f5fee0a9cc2bd5568026
3
+ metadata.gz: 823e1b368b305c5efc2b457268ea4a9abfaeabee
4
+ data.tar.gz: db9cbbb65d929292ea8451268729475e54b2678b
5
5
  SHA512:
6
- metadata.gz: d9577f2279e43d4efbf4df155237311f3bc96f3f182a731d53addb084f0d9f610b0457b5911ea7d2bb1feac4f63cec238250204b556e94def0e7f907b74bfa62
7
- data.tar.gz: b906e8c1f4330f235ae15f8fce26b88a2846f267f7d921c5867b8b536b3d5bc59a40733703008e62a6c5ff4314424392f797ad71846d1b61c2c33386251e730a
6
+ metadata.gz: fad9bba141eedf53cc2e42b821ad894c41a7bfea87022c1008e13f7b8fc15991996b3a47db94692ee6f368aed9bf81b5e7586b79da86fc915ebc735a3371690b
7
+ data.tar.gz: 2a4b0819fa5bd035d55ca69100ae3f55b0b08696db9d1548bd57fef8269b547051e80054bd2832b8ef6b397e34cab1e547ec46ddd5d0c4d432c912eb670edd09
@@ -14,12 +14,16 @@ class Hedgerow
14
14
 
15
15
  def lock(name, timeout)
16
16
  validate_name!(name)
17
- parse_response connection.prepare("SELECT GET_LOCK(?, ?)").execute(name, timeout)
17
+ connection do |c|
18
+ parse_response c.prepare("SELECT GET_LOCK(?, ?)").execute(name, timeout)
19
+ end
18
20
  end
19
21
 
20
22
  def release(name)
21
23
  validate_name!(name)
22
- parse_response connection.prepare("SELECT RELEASE_LOCK(?)").execute(name)
24
+ connection do |c|
25
+ parse_response c.prepare("SELECT RELEASE_LOCK(?)").execute(name)
26
+ end
23
27
  end
24
28
 
25
29
  def validate_name!(name)
@@ -38,12 +42,14 @@ class Hedgerow
38
42
  end
39
43
 
40
44
  def connection
41
- @@connection ||= begin
42
- if defined?(ActiveRecord)
43
- ActiveRecord::Base.connection.raw_connection
44
- else
45
- raise "Could not find connection for hedgerow."
45
+ if defined?(ActiveRecord)
46
+ ActiveRecord::Base.connection_pool.with_connection do |connection|
47
+ yield connection.raw_connection
46
48
  end
49
+ elsif @@connection
50
+ yield @@connection
51
+ else
52
+ raise "Could not find connection for hedgerow."
47
53
  end
48
54
  end
49
55
  end
@@ -1,3 +1,3 @@
1
1
  class Hedgerow
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hedgerow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Hallett
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-06-04 00:00:00.000000000 Z
11
+ date: 2018-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler