iron_trail 0.2.2 → 0.3.0.pre.alpha1

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
  SHA256:
3
- metadata.gz: 53e65b9972a06bb052bf64095ab551e9da2da8068d2e6dc4f99b212807d00efc
4
- data.tar.gz: 26d20d4244935be46e0734ca97135a0708bc055cc766d97f34c777f5fa5c4630
3
+ metadata.gz: 5f71f8c85d8b8b0bb81528cba7696a279cd012a85035f4882f61607a4f032778
4
+ data.tar.gz: b9aaf678019f278724a510cfd6df566288976939dda0f5f37aa67b01538a9ab4
5
5
  SHA512:
6
- metadata.gz: '091d403022eb43516db646a17c96f9a65d1367dca2e845d0ebd7ca4d614edfa774a2fc88bbbbae5d89aaaca134d3ef255408594a0c176805834709257d02ee59'
7
- data.tar.gz: 8bad5c9401a1bcb21d6504027944ccd8346fcbfdcad6730fc6155468ba0671050027395b293c3219285071b13e4ee71838266b4005bcb0dd06bdee8933f677f6
6
+ metadata.gz: 56f449260f7c0f83cde52d4311e370828bf2a4d0250f6490003de296066e2717f56afebc969dfe97d74fba2ecefd1a43d72236bdc32450ce7384f1e3b8fc9a56
7
+ data.tar.gz: 1b3ce44bad0e293d3c6eb38e21d1d076713ff53240bce114bcb5504f74457db94dc4978cfacb8d182ec590ae08aa5d67008d2e06a923bf8ae17aacaa05053fec
@@ -27,7 +27,7 @@ module IronTrail
27
27
  attr_accessor :enabled
28
28
 
29
29
  def enable!
30
- DbFunctions.new(ActiveRecord::Base.connection).install_functions
30
+ with_connection { |conn| DbFunctions.new(conn).install_functions }
31
31
  @enabled = true
32
32
  end
33
33
 
@@ -44,7 +44,7 @@ module IronTrail
44
44
  $$ LANGUAGE plpgsql;
45
45
  SQL
46
46
 
47
- ActiveRecord::Base.connection.execute(sql)
47
+ with_connection { |conn| conn.execute(sql) }
48
48
  @enabled = false
49
49
  end
50
50
 
@@ -65,6 +65,20 @@ module IronTrail
65
65
  ::IronTrail::Testing.enable!
66
66
  end
67
67
  end
68
+
69
+ private
70
+
71
+ # Checks out a connection for the duration of the block, mirroring
72
+ # ActiveRecord::Base.with_connection (Rails 7.2+). On Rails 7.1, where
73
+ # that method does not exist yet, it falls back to yielding the
74
+ # (soft-deprecated on Rails 8.1+) ActiveRecord::Base.connection.
75
+ def with_connection(&block)
76
+ if ActiveRecord::Base.respond_to?(:with_connection)
77
+ ActiveRecord::Base.with_connection(&block)
78
+ else
79
+ yield ActiveRecord::Base.connection
80
+ end
81
+ end
68
82
  end
69
83
  end
70
84
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_literal_string: true
2
2
 
3
3
  module IronTrail
4
- VERSION = '0.2.2'
4
+ VERSION = '0.3.0-alpha1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iron_trail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0.pre.alpha1
5
5
  platform: ruby
6
6
  authors:
7
7
  - André Diego Piske
@@ -166,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
166
  - !ruby/object:Gem::Version
167
167
  version: '0'
168
168
  requirements: []
169
- rubygems_version: 4.0.6
169
+ rubygems_version: 4.0.16
170
170
  specification_version: 4
171
171
  summary: Creates a trail strong as iron
172
172
  test_files: []