short_circu_it 0.6.0.pre → 0.6.0.pre2
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 +11 -14
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b792f7aa950ffdc6488504175694615fe24ec827a7ce1eea39820911ee0832ac
|
4
|
+
data.tar.gz: ce2095acdb61f385227b30968e01eda49a8d451fd968fc23662344b3f7c2c7f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea6446e52f951323622acf042ce0c91c29abd47fdf367f6800b9f95fc638319145b84a187524c2238664dba98df3aec3c91862f98bef3340436b400ab98784f9
|
7
|
+
data.tar.gz: 32b8c096395b9e65de1a5cf852ccf9bce850aad27f832aa9591fee35f02227e22e6d85a3780cb0368c502ef60bf0c3b041a4e8b782923fa61dcf105287eb44b4
|
data/lib/short_circu_it.rb
CHANGED
@@ -65,25 +65,22 @@ module ShortCircuIt
|
|
65
65
|
# * database stuff *
|
66
66
|
# => #<SomeAssociation:2468 id: 2>
|
67
67
|
#
|
68
|
-
# @param
|
68
|
+
# @param *method_names [Symbol] The name(s) of one or more methods to be memoized
|
69
69
|
# @param :observes [Symbol, Array<Symbol>]
|
70
70
|
# A method or array of methods to be observed to determine memoization cache validity.
|
71
71
|
# If any of the observed values change, the cached value will be invalidated.
|
72
72
|
# By default, the object will observe itself.
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
# Default: false
|
77
|
-
def memoize(method_name, observes: :itself, memoize_subclasses: false)
|
78
|
-
add_memoized_observers(method_name.to_sym, observes)
|
73
|
+
def memoize(*method_names, observes: :itself)
|
74
|
+
method_names.map(&:to_sym).each do |method_name|
|
75
|
+
add_memoized_observers(method_name, observes)
|
79
76
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
77
|
+
around_method(
|
78
|
+
method_name,
|
79
|
+
prevent_double_wrapping_for: ShortCircuIt,
|
80
|
+
) do |*args|
|
81
|
+
memoization_store.memoize(method_name, args.hash) do
|
82
|
+
super(*args)
|
83
|
+
end
|
87
84
|
end
|
88
85
|
end
|
89
86
|
end
|
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.6.0.
|
4
|
+
version: 0.6.0.pre2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Allen Rettberg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-03-12 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.6.0.
|
33
|
+
version: 0.6.0.pre2
|
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.6.0.
|
40
|
+
version: 0.6.0.pre2
|
41
41
|
description: Memoize methods safely with parameter and dependency observation
|
42
42
|
email:
|
43
43
|
- allen.rettberg@freshly.com
|
@@ -70,8 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
70
|
- !ruby/object:Gem::Version
|
71
71
|
version: 1.3.1
|
72
72
|
requirements: []
|
73
|
-
|
74
|
-
rubygems_version: 2.7.6
|
73
|
+
rubygems_version: 3.0.3
|
75
74
|
signing_key:
|
76
75
|
specification_version: 4
|
77
76
|
summary: Effortless memoization
|