goldiloader 4.0.1 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3da0240495233f97f9762b4c81249b24fc6b9fb39e46801243e865ae2ed4d50d
4
- data.tar.gz: d5bc7704557c4a9cdaf4e8d8e31d7d066444a964faf31812ce34117f845ccbeb
3
+ metadata.gz: d30741df3c728239a50f4668f908f40cb0be785d5403848648faccc32b329d9d
4
+ data.tar.gz: 7032140f7401f0e47ac717b48d1089a6211d1ea7c78c3c64a1c0879882a47fbc
5
5
  SHA512:
6
- metadata.gz: 73ab77e3c22b3e80dc903079dfe65245fceae13ab8b4fa1870705df1d1302eac82982523fad9cf7b9c2f4576022894ff16c8cd83b72d966ede5cd88ffb2b56d0
7
- data.tar.gz: 402c5bfe96112e1a697af866205c3a16cb85966566adcac722deefc4ce4d487b4df10e335d1ce057cb2ddcf5ce4c8d490998c46b3e20feca4d98f334f2719534
6
+ metadata.gz: b9ae29eddaba860fa1a9075aae6788629f56e2d47bb71afef20dc39f587070c8572820694d1650a50d625d142739de419c7c9617a6cae6b6a4257fd753a3b2a8
7
+ data.tar.gz: cf79ee0b429d1716371ae655cae72dc811fec672d53c69409f24a46301326e90c5a2c02f60332b7ec3e4581c7a984e2cfbdb658fdbca11c8df340e53f9c217bc
data/lib/goldiloader.rb CHANGED
@@ -8,3 +8,37 @@ require 'goldiloader/scope_info'
8
8
  require 'goldiloader/association_options'
9
9
  require 'goldiloader/association_loader'
10
10
  require 'goldiloader/active_record_patches'
11
+
12
+ module Goldiloader
13
+ class << self
14
+
15
+ # Sets the process-wide enabled status
16
+ attr_accessor :globally_enabled
17
+
18
+ def enabled?
19
+ Thread.current.fetch(:goldiloader_enabled, globally_enabled)
20
+ end
21
+
22
+ def enabled=(val)
23
+ Thread.current[:goldiloader_enabled] = val
24
+ end
25
+
26
+ def enabled
27
+ old_enabled = enabled?
28
+ self.enabled = true
29
+ yield
30
+ ensure
31
+ self.enabled = old_enabled
32
+ end
33
+
34
+ def disabled
35
+ old_enabled = enabled?
36
+ self.enabled = false
37
+ yield
38
+ ensure
39
+ self.enabled = old_enabled
40
+ end
41
+ end
42
+
43
+ self.globally_enabled = true
44
+ end
@@ -119,6 +119,8 @@ module Goldiloader
119
119
  end
120
120
 
121
121
  def load_with_auto_include
122
+ return yield unless Goldiloader.enabled?
123
+
122
124
  if loaded? && !stale_target?
123
125
  target
124
126
  elsif !auto_include?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Goldiloader
4
- VERSION = '4.0.1'
4
+ VERSION = '4.1.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: goldiloader
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Turkel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-09 00:00:00.000000000 Z
11
+ date: 2021-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord