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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 589b739844b381707d83e9dcd9c81008951e388c9fbb5361821f9d3ead7f9c60
4
- data.tar.gz: 6c3e96182dea40b2693db9937f434cff394aaa1b71c88c28f375a53cd13874d7
3
+ metadata.gz: '068ad78c5ca6426134080648451b94d4243130e39e985b3cc98edae3044a5f20'
4
+ data.tar.gz: e498ebe3a522f57a0fcfdd4e0ea7e1ccb096ec26adb6f73dce0badc1ee7cf935
5
5
  SHA512:
6
- metadata.gz: 187ec3e55ed71647a49c0379c2cbf855b9ce94c266b3e7d1183d1deafcb568cc9305ba5d92d8256872fe998e02816f4f0a75e9a7ddc850d44c754e17c56c8609
7
- data.tar.gz: f442100c27d3165c5388f75bb4d6e5c72a8c37c7a50151b5c593bfb5e82df77cb045a366a3e4d08d40b172898d277964ed8d3aaabef32a494bd50e80fb0cd18c
6
+ metadata.gz: be5728d2629e1a192a3e6f89f089159f0fad2eadc778213836474fa52688e509414b2b0b048e38665e2c267dc30ac3e8669d4edf27cfdae64a4f81dc6b465156
7
+ data.tar.gz: 2fd4ae72e455d1e29f43451c9bbde94aa9381fcc02c9c5843628db3a6eb9fcf00a0623a55a683f90d8bad75edb30d52064ea9d7c929fff53b0a6ae65eba28636
@@ -1,3 +1,3 @@
1
1
  module Memoit
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
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.0
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-19 00:00:00.000000000 Z
11
+ date: 2022-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler