effective_resources 2.1.3 → 2.1.4

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: 91015a3de5ffe3fd8727b1076558a95eedd3601ce768cf7c24befa42635c6a1b
4
- data.tar.gz: 655794c38fa9b32c7fd40692469fe255152820e497d727a69336429d8f7e3acc
3
+ metadata.gz: 5c6a9d06e7d62a4fa96c365b8e6386d4229585ed5c0963b3f55b435ed4b7cbf4
4
+ data.tar.gz: 84459f1187673d432756a4e3fccf6b163f3b5f55af26a7c1c485938e892d9e95
5
5
  SHA512:
6
- metadata.gz: 427908e33318358ca2a00ea9d578585cd18ae62dd952016e129878ebc778303084c8af06ba5dbb2d919440f9d5a0733788895cd8d77a38224915e84381d6755b
7
- data.tar.gz: 53fa67e820609b4349e1623975aee917954d865cf85dba56e27b70000a953b1394d17ab098f684a900cf60274ea25ec71e56c952f5f146822fe04c9bc39299ad
6
+ metadata.gz: f76ef089d1b702f51948cf5ec7b03fc8fe9529428190225b9e27bddbc91c83c3e8d9b01911a2ae5d97efcae22cd8e2f77dd0d642b32b5184b459a6ccb4e3bbfa
7
+ data.tar.gz: 6e13de73624c865c3312d2af94816890769599ed2aa1d89e4cde5251d545d25583a14293b04d2a152cc493c2c6c222015cba326e09dec19310771668bda2b8ab
@@ -40,7 +40,13 @@ module ActsAsSlugged
40
40
  return super unless args.length == 1
41
41
  return super if block_given?
42
42
 
43
- where(slug: args.first).first || raise(::ActiveRecord::RecordNotFound.new("Couldn't find #{name} with 'slug'=#{args.first}"))
43
+ reloading = instance_variable_get(:@_effective_reloading)
44
+ reloading ||= self.class.instance_variable_get(:@_effective_reloading)
45
+ reloading ||= klass.instance_variable_get(:@_effective_reloading) if respond_to?(:klass)
46
+
47
+ return find_by_id(args.first) if reloading
48
+
49
+ find_by_slug(args.first) || raise(::ActiveRecord::RecordNotFound.new("Couldn't find #{name} with 'slug'=#{args.first}"))
44
50
  end
45
51
 
46
52
  def find_by_slug_or_id(*args)
@@ -68,4 +74,16 @@ module ActsAsSlugged
68
74
  slug_was || slug
69
75
  end
70
76
 
77
+ def to_global_id(**params)
78
+ params[:tenant] = Tenant.current if defined?(Tenant)
79
+ GlobalID.new(URI::GID.build(app: Rails.application.config.global_id.app, model_name: model_name, model_id: to_param, params: params))
80
+ end
81
+
82
+ def reload(options = nil)
83
+ self.class.instance_variable_set(:@_effective_reloading, true)
84
+ retval = super
85
+ self.class.instance_variable_set(:@_effective_reloading, nil)
86
+ retval
87
+ end
88
+
71
89
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '2.1.3'.freeze
2
+ VERSION = '2.1.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.3
4
+ version: 2.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-28 00:00:00.000000000 Z
11
+ date: 2022-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails