mem 0.1.0 → 0.1.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
  SHA1:
3
- metadata.gz: ac41bdc5119cf45f7824c911ae16f5df3e2c808d
4
- data.tar.gz: 1f63987a155340dacbffc0d19648bdc08b5c9970
3
+ metadata.gz: a6ca181d52b428f217e48d148ca5f0e5e336d83f
4
+ data.tar.gz: 929cbdf292bf772d4d8bb670bea88bfce549fdfb
5
5
  SHA512:
6
- metadata.gz: 3166d66167e8b19d45e281f57c289cee57d34ecd0eca5e3f0608bac09381a45b8b596d675cacebbe1f5714fbc8b8feac9384905939049af65d470abe2810ec05
7
- data.tar.gz: a9b281277509b6731eda20c6c65d8985de7a930d8f4fc4fa70b057df093b7ab92a68e71ab325a23497180845287a2025dcbcfec0d45045abaaf8a1901066c688
6
+ metadata.gz: 3391b30516dbdd09d794f1127f8e46dbee602bd0670d3802ff6911e6a939d426639e14e3700085149bbb4d4e2753fbdd5be7af7f5bb987a719a645305cc80fe7
7
+ data.tar.gz: c4c11d2f1e1ffc7d8ec2c9aed618770a0d76cddfaf13677f865358ed1e5559b866dd494e325fc743097ceb6ad0b0356328d472ba16acc1f1fbe7e8430acb042a
@@ -1,3 +1,6 @@
1
+ ## 0.1.1
2
+ * Define setter on `.memoize`
3
+
1
4
  ## 0.1.0
2
5
  * Change interface from `extend Mem` to `include Mem`
3
6
  * Change stored data structure from ivar to hash table
data/lib/mem.rb CHANGED
@@ -32,6 +32,10 @@ module Mem
32
32
  end
33
33
  alias_method "#{method_name}_without_memoize", method_name
34
34
  alias_method method_name, "#{method_name}_with_memoize"
35
+
36
+ define_method("#{method_name}=") do |value|
37
+ memoize(method_name, value)
38
+ end
35
39
  end
36
40
  end
37
41
  end
@@ -1,3 +1,3 @@
1
1
  module Mem
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -19,6 +19,11 @@ describe Mem do
19
19
  def b(value)
20
20
  [value, yield]
21
21
  end
22
+
23
+ def c
24
+ "c"
25
+ end
26
+ memoize :c
22
27
  end
23
28
  end
24
29
 
@@ -27,9 +32,15 @@ describe Mem do
27
32
  expect(object.a(1) { 2 }).to eq [1, 2]
28
33
  expect(object.a(3) { 4 }).to eq [1, 2]
29
34
  end
35
+
36
+ it "defines setter" do
37
+ expect(object.c).to eq "c"
38
+ object.c = "d"
39
+ expect(object.c).to eq "d"
40
+ end
30
41
  end
31
42
 
32
- context "with normal method name" do
43
+ context "with abnormal method name" do
33
44
  let(:klass) do
34
45
  Class.new do
35
46
  include Mem
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-22 00:00:00.000000000 Z
11
+ date: 2014-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
@@ -59,7 +59,7 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
- - .gitignore
62
+ - ".gitignore"
63
63
  - CHANGELOG.md
64
64
  - Gemfile
65
65
  - LICENSE.txt
@@ -80,12 +80,12 @@ require_paths:
80
80
  - lib
81
81
  required_ruby_version: !ruby/object:Gem::Requirement
82
82
  requirements:
83
- - - '>='
83
+ - - ">="
84
84
  - !ruby/object:Gem::Version
85
85
  version: '0'
86
86
  required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - '>='
88
+ - - ">="
89
89
  - !ruby/object:Gem::Version
90
90
  version: '0'
91
91
  requirements: []
@@ -97,4 +97,3 @@ summary: Memoize any method call
97
97
  test_files:
98
98
  - spec/mem_spec.rb
99
99
  - spec/spec_helper.rb
100
- has_rdoc: