eac_ruby_utils 0.62.0 → 0.62.1

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: c935490ddb854abc0f1aa8e473a020d6636aca5805a1312849cc3be308140798
4
- data.tar.gz: '00932149f86866358f22288a3e4aa434d59b4164140ce76dda55b9f88d310bd1'
3
+ metadata.gz: 76b0e92df72f0b6b552d62eda2aad5f2701409e7d8093aee4d30c5df70ee30a1
4
+ data.tar.gz: b6450dc7143e3a1669df002394357c2209d51983111cefc2d8f25efbd8e5344a
5
5
  SHA512:
6
- metadata.gz: fe63c4031d9240b8bc18dfa3b4ff39edac9465c1056971feadeb9338f8c2e4a59836fdafc5268c35dcc4158348c84c50da255b7b4e320554f56e73300b83e4e6
7
- data.tar.gz: ecb86c9203690924b8263e5934f093bbf53e2218bf9b2019ccb188afc896e3ffcc21abd8565c1641bc1ab94936f909870f80413e232161092076b4163c53bab4
6
+ metadata.gz: 7839203f7f9e9a8baa17167e4a5e0d9d812ff9028de3fb3c8298ce6bb584f6b77256b8afdfd49ff79f23d0614afcef74aa5f003ab00a0d3fc14d58816e695fce
7
+ data.tar.gz: 9392bdfc10d5a2ba53de62a816c307e0d2f3e21b6731888cc0fe63a46853ed5c074d91fafc5f91194256fa33c6ddb39a930c75564db7aac3ff3967c9e4329eee
@@ -2,12 +2,18 @@
2
2
 
3
3
  module EacRubyUtils
4
4
  module SimpleCache
5
- UNCACHED_METHOD_PATTERN = /\A(\s+)_uncached\z/.freeze
5
+ UNCACHED_METHOD_NAME_SUFFIX = '_uncached'
6
+ UNCACHED_METHOD_PATTERN = /\A(\s+)_#{::Regexp.quote(UNCACHED_METHOD_NAME_SUFFIX)}\z/.freeze
7
+
8
+ class << self
9
+ def uncached_method_name(method_name)
10
+ "#{method_name}#{UNCACHED_METHOD_NAME_SUFFIX}"
11
+ end
12
+ end
6
13
 
7
14
  def method_missing(method, *args, &block)
8
- uncached_method = "#{method}_uncached"
9
- if respond_to?(uncached_method, true)
10
- call_method_with_cache(uncached_method, args, &block)
15
+ if respond_to?(::EacRubyUtils::SimpleCache.uncached_method_name(method), true)
16
+ call_method_with_cache(method, args, &block)
11
17
  else
12
18
  super
13
19
  end
@@ -35,10 +41,17 @@ module EacRubyUtils
35
41
  raise 'Não é possível realizar o cache de métodos com bloco' if block
36
42
 
37
43
  key = ([method] + args).join('@@@')
38
- cache_keys[key] = send(method, *args) unless cache_keys.key?(key)
44
+ unless cache_keys.key?(key)
45
+ uncached_value = call_uncached_method(method, args)
46
+ cache_keys[key] = uncached_value
47
+ end
39
48
  cache_keys[key]
40
49
  end
41
50
 
51
+ def call_uncached_method(method, args)
52
+ send(::EacRubyUtils::SimpleCache.uncached_method_name(method), *args)
53
+ end
54
+
42
55
  def cache_keys
43
56
  @cache_keys ||= {}
44
57
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.62.0'
4
+ VERSION = '0.62.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_ruby_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.62.0
4
+ version: 0.62.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-28 00:00:00.000000000 Z
11
+ date: 2021-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport