memoit 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/memoit/version.rb +1 -1
- data/lib/memoit.rb +1 -1
- data/spec/memoit_spec.rb +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '068ad78c5ca6426134080648451b94d4243130e39e985b3cc98edae3044a5f20'
|
4
|
+
data.tar.gz: e498ebe3a522f57a0fcfdd4e0ea7e1ccb096ec26adb6f73dce0badc1ee7cf935
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be5728d2629e1a192a3e6f89f089159f0fad2eadc778213836474fa52688e509414b2b0b048e38665e2c267dc30ac3e8669d4edf27cfdae64a4f81dc6b465156
|
7
|
+
data.tar.gz: 2fd4ae72e455d1e29f43451c9bbde94aa9381fcc02c9c5843628db3a6eb9fcf00a0623a55a683f90d8bad75edb30d52064ea9d7c929fff53b0a6ae65eba28636
|
data/lib/memoit/version.rb
CHANGED
data/lib/memoit.rb
CHANGED
@@ -17,7 +17,7 @@ module Memoit
|
|
17
17
|
define_method(name) do |*args, **kwargs, &block|
|
18
18
|
return super(*args, **kwargs, &block) if block
|
19
19
|
cache = instance_variable_get(ivar_name) || instance_variable_set(ivar_name, {})
|
20
|
-
cache.fetch(args.hash) { |hash| cache[hash] = super(*args, **kwargs) }
|
20
|
+
cache.fetch([args, kwargs].hash) { |hash| cache[hash] = super(*args, **kwargs) }
|
21
21
|
end
|
22
22
|
end
|
23
23
|
prepend mod
|
data/spec/memoit_spec.rb
CHANGED
@@ -79,6 +79,10 @@ describe Memoit do
|
|
79
79
|
expect(instance.quux(kwak: "kwav")).to eq(instance.quux(kwak: "kwav"))
|
80
80
|
end
|
81
81
|
|
82
|
+
it "ignores cache if keyword arguments differ" do
|
83
|
+
expect(instance.quux(kwak: "1")).not_to eq(instance.quux(kwak: "2"))
|
84
|
+
end
|
85
|
+
|
82
86
|
it "caches results when hash and keyword arguments are used" do
|
83
87
|
expect(instance.corge({ hash_key: "hash_value" }, kwak: "kwav")).to eq(instance.corge({ hash_key: "hash_value" }, kwak: "kwav"))
|
84
88
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: memoit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Nicklas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-07-
|
11
|
+
date: 2022-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|