short_circu_it 0.5.0 → 0.6.0.pre
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.rb +14 -5
- data/lib/short_circu_it/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b33b859e595e10c199fdd17bd805206e1035e5d879e442386a8d852b3121c44d
|
4
|
+
data.tar.gz: a2abbe0325968d9f7e9b0b4b2c14bc2c73e63ecddc0bafa69c2798929942a502
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2414b41886dd4acb0f991a5ee4ab2c2a23d60ed508738af91497c61a195ea9b816655624fc767573566d8b41cb52d0757ab9a58d9b69862f4a4a3073cddc9c44
|
7
|
+
data.tar.gz: b0a3c74002e77db75b7a204d328a4f48f57eb9e4b0315cf14b3665f59d6be6ec8950b548d841ae9916d3da399c04d6b8294a2883cc0ead8ff3a343490c9cbb25
|
data/lib/short_circu_it.rb
CHANGED
@@ -66,13 +66,22 @@ module ShortCircuIt
|
|
66
66
|
# => #<SomeAssociation:2468 id: 2>
|
67
67
|
#
|
68
68
|
# @param method_name [Symbol] The name of the method to be memoized
|
69
|
-
# @param :observes [Symbol, Array<Symbol>]
|
70
|
-
#
|
71
|
-
#
|
72
|
-
|
69
|
+
# @param :observes [Symbol, Array<Symbol>]
|
70
|
+
# A method or array of methods to be observed to determine memoization cache validity.
|
71
|
+
# If any of the observed values change, the cached value will be invalidated.
|
72
|
+
# By default, the object will observe itself.
|
73
|
+
# @param :memoize_subclasses [Boolean]
|
74
|
+
# If true, method will be memoized in subclasses that redefine the method.
|
75
|
+
# If false, subclasses that redefine the method will not memoizee the resolveed value.
|
76
|
+
# Default: false
|
77
|
+
def memoize(method_name, observes: :itself, memoize_subclasses: false)
|
73
78
|
add_memoized_observers(method_name.to_sym, observes)
|
74
79
|
|
75
|
-
around_method
|
80
|
+
around_method(
|
81
|
+
method_name.to_sym,
|
82
|
+
prevent_double_wrapping_for: ShortCircuIt,
|
83
|
+
wrap_subclasses: memoize_subclasses,
|
84
|
+
) do |*args|
|
76
85
|
memoization_store.memoize(method_name.to_sym, args.hash) do
|
77
86
|
super(*args)
|
78
87
|
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.
|
4
|
+
version: 0.6.0.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Allen Rettberg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-21 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.6.0.pre
|
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.6.0.pre
|
41
41
|
description: Memoize methods safely with parameter and dependency observation
|
42
42
|
email:
|
43
43
|
- allen.rettberg@freshly.com
|
@@ -66,9 +66,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
66
66
|
version: '0'
|
67
67
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
68
|
requirements:
|
69
|
-
- - "
|
69
|
+
- - ">"
|
70
70
|
- !ruby/object:Gem::Version
|
71
|
-
version:
|
71
|
+
version: 1.3.1
|
72
72
|
requirements: []
|
73
73
|
rubyforge_project:
|
74
74
|
rubygems_version: 2.7.6
|