my_stuff-multidb 0.0.2 → 0.0.3

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.
@@ -16,6 +16,12 @@ module MyStuff
16
16
  self
17
17
  end
18
18
 
19
+ def with_spec spec
20
+ MyStuff::MultiDB.with_spec(
21
+ db, spec
22
+ ) { |*args| yield *args }
23
+ end
24
+
19
25
  def magic_database
20
26
  @magic_database ||= self.name.split('::').tap(&:pop).join('::').constantize.magic_database
21
27
  end
@@ -157,6 +157,14 @@ module MyStuff
157
157
  return db_mod
158
158
  end
159
159
 
160
+ def self.with_spec db, spec # :nodoc:
161
+ klass = db.for_spec(spec)
162
+
163
+ klass.magic_database.connection_pool.with_connection do
164
+ yield klass, spec
165
+ end
166
+ end
167
+
160
168
  protected
161
169
  def self.with_db db, id, writable # :nodoc:
162
170
  if writable == :writable
@@ -168,10 +176,9 @@ module MyStuff
168
176
  elsif writable == :read_only
169
177
  spec = db.spec_for_slave(id)
170
178
  end
171
- klass = db.for_spec(spec)
172
179
 
173
- klass.magic_database.connection_pool.with_connection do
174
- yield klass, spec
180
+ with_spec(db, spec) do |*args|
181
+ yield *args
175
182
  end
176
183
  end
177
184
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: my_stuff-multidb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-09-04 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: my_stuff-logger
16
- requirement: &70305004706900 !ruby/object:Gem::Requirement
16
+ requirement: &70289582101220 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,18 +21,18 @@ dependencies:
21
21
  version: 0.0.3
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70305004706900
24
+ version_requirements: *70289582101220
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: activerecord
27
- requirement: &70305004704620 !ruby/object:Gem::Requirement
27
+ requirement: &70289582100640 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
- - - ~>
30
+ - - ! '>='
31
31
  - !ruby/object:Gem::Version
32
- version: 3.0.7
32
+ version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70305004704620
35
+ version_requirements: *70289582100640
36
36
  description: ''
37
37
  email:
38
38
  - mail@fredemmott.co.uk