short_circu_it 0.4.3 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/short_circu_it/version.rb +1 -1
- data/lib/short_circu_it.rb +6 -6
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 592a5e9f48efa007083f97ccf469ab400f526fc3f422a6db53fccd29974548b2
|
4
|
+
data.tar.gz: 5903506ebb5f4cb60e6e6e9cda050e1b62e3bfd33884fce201ce6c0416378d07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc96ea51eeec2ad20ec71040b1cf3a5748a84051cb24999618a034d02d97f7bcbf060aefc1431cb9ca32c340abb62afdf94ca315baa74e77dd98c7f112002bbf
|
7
|
+
data.tar.gz: 71b657f2dc9a749004f69bd5e0df34adae263d9ecfeb6a7dec47a61c7db359a540ab137b3eb9ffa731057eca3a43e460ab32db2abf9f4dd5ff7e5b8a24cab4df
|
data/lib/short_circu_it.rb
CHANGED
@@ -12,8 +12,6 @@ module ShortCircuIt
|
|
12
12
|
extend ActiveSupport::Concern
|
13
13
|
include AroundTheWorld
|
14
14
|
|
15
|
-
PREPEND_MODULE_NAME = "MemoizedMethods"
|
16
|
-
|
17
15
|
included do
|
18
16
|
delegate :memoization_observers, to: :class
|
19
17
|
delegate :clear_memoization, :clear_all_memoization, to: :memoization_store
|
@@ -27,7 +25,10 @@ module ShortCircuIt
|
|
27
25
|
end
|
28
26
|
|
29
27
|
class_methods do
|
30
|
-
|
28
|
+
def memoization_observers
|
29
|
+
@memoization_observers ||=
|
30
|
+
superclass.respond_to?(:memoization_observers) ? superclass.memoization_observers : {}
|
31
|
+
end
|
31
32
|
|
32
33
|
protected
|
33
34
|
|
@@ -71,7 +72,7 @@ module ShortCircuIt
|
|
71
72
|
def memoize(method_name, observes: :itself)
|
72
73
|
add_memoized_observers(method_name.to_sym, observes)
|
73
74
|
|
74
|
-
around_method method_name.to_sym,
|
75
|
+
around_method method_name.to_sym, prevent_double_wrapping_for: ShortCircuIt do |*args|
|
75
76
|
memoization_store.memoize(method_name.to_sym, args.hash) do
|
76
77
|
super(*args)
|
77
78
|
end
|
@@ -80,11 +81,10 @@ module ShortCircuIt
|
|
80
81
|
|
81
82
|
private
|
82
83
|
|
83
|
-
|
84
|
+
attr_writer :memoization_observers
|
84
85
|
|
85
86
|
def add_memoized_observers(method_name, observers)
|
86
87
|
# TODO: Raise an error if method has already been memoized? A warning maybe?
|
87
|
-
self.memoization_observers ||= {}
|
88
88
|
self.memoization_observers = memoization_observers.
|
89
89
|
merge(method_name.to_sym => Array.wrap(observers).freeze).
|
90
90
|
freeze
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: short_circu_it
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Allen Rettberg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.5.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 0.5.0
|
41
41
|
description: Memoize methods safely with parameter and dependency observation
|
42
42
|
email:
|
43
43
|
- allen.rettberg@freshly.com
|