memoist 0.9.2 → 0.9.3

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: 630e2e80eea33c244c75ee3cab805415e627f357
4
- data.tar.gz: 4e7760bdbe28b2e7aee579e722c80142cc775976
3
+ metadata.gz: 05bd6cfd3935ea3d449651b5a997497699b5ba47
4
+ data.tar.gz: 5e9fcd26cd38218270949a2757a9b1832ea63969
5
5
  SHA512:
6
- metadata.gz: 99ea31ce66097c7350d6f1393bfdb322b9002d145674caa68e04545ec082a4db8da671553f21198463125685275194843e55a256ae9315c7cdccdcf344b4e548
7
- data.tar.gz: 24b7a97927feb6a684e1c1dcc31b827510ccccb194b176de04ab852cdc1d5d8a88be845a79c6f1d3c0317341b154f4c44253d0133d8d65623cdc4281f152bafe
6
+ metadata.gz: 4369588f404fd7fa811c6b32af02998b656e13a95058018698ee9b2c67674b8da300c5ff6b736ce0d5f0a0ecbf5aee2f022756c26fce72edfea5fcad34123cd4
7
+ data.tar.gz: 9a07124cccbd25d30fbac70a2303b4b239a3871f50a261ba1d50e1a5c58402d04300fc1e930f780ceb1263f0e8097048846ea73ad4866f3c6112103ca84a596e
data/.travis.yml CHANGED
@@ -6,5 +6,5 @@ rvm:
6
6
  - 1.8.7
7
7
  - jruby-18mode
8
8
  - jruby-19mode
9
- - rbx
9
+ - rbx-2
10
10
 
data/lib/memoist.rb CHANGED
@@ -78,7 +78,7 @@ module Memoist
78
78
 
79
79
  method_names.each do |method_name|
80
80
  ivar = Memoist.memoized_ivar_for(method_name)
81
- instance_variable_get(ivar).clear if instance_variable_defined?(ivar)
81
+ remove_instance_variable(ivar) if instance_variable_defined?(ivar)
82
82
  end
83
83
  end
84
84
  end
@@ -105,17 +105,17 @@ module Memoist
105
105
  # define a method like this;
106
106
 
107
107
  # def mime_type(reload=true)
108
- # skip_cache = reload || !memoized?(:abc)
108
+ # skip_cache = reload || !instance_variable_defined?("@_memoized_mime_type")
109
109
  # set_cache = skip_cache && !frozen?
110
110
  #
111
111
  # if skip_cache
112
112
  # value = _unmemoized_mime_type
113
113
  # else
114
- # value = @_memoized_mime_type[0]
114
+ # value = @_memoized_mime_type
115
115
  # end
116
116
  #
117
117
  # if set_cache
118
- # @_memoized_mime_type = [value]
118
+ # @_memoized_mime_type = value
119
119
  # end
120
120
  #
121
121
  # value
@@ -123,17 +123,17 @@ module Memoist
123
123
 
124
124
  module_eval <<-EOS, __FILE__, __LINE__ + 1
125
125
  def #{method_name}(reload = false)
126
- skip_cache = reload || !defined?(#{memoized_ivar}) || #{memoized_ivar}.empty?
126
+ skip_cache = reload || !instance_variable_defined?("#{memoized_ivar}")
127
127
  set_cache = skip_cache && !frozen?
128
128
 
129
129
  if skip_cache
130
130
  value = #{unmemoized_method}
131
131
  else
132
- value = #{memoized_ivar}[0]
132
+ value = #{memoized_ivar}
133
133
  end
134
134
 
135
135
  if set_cache
136
- #{memoized_ivar} = [value]
136
+ #{memoized_ivar} = value
137
137
  end
138
138
 
139
139
  value
@@ -167,7 +167,7 @@ module Memoist
167
167
  def #{method_name}(*args)
168
168
  reload = Memoist.extract_reload!(method(#{unmemoized_method.inspect}), args)
169
169
 
170
- skip_cache = reload || !(defined?(#{memoized_ivar}) && #{memoized_ivar} && #{memoized_ivar}.has_key?(args))
170
+ skip_cache = reload || !(instance_variable_defined?(#{memoized_ivar.inspect}) && #{memoized_ivar} && #{memoized_ivar}.has_key?(args))
171
171
  set_cache = skip_cache && !frozen?
172
172
 
173
173
  if skip_cache
@@ -1,3 +1,3 @@
1
1
  module Memoist
2
- VERSION = "0.9.2"
2
+ VERSION = "0.9.3"
3
3
  end
data/test/memoist_test.rb CHANGED
@@ -202,9 +202,10 @@ class MemoistTest < Test::Unit::TestCase
202
202
  def test_flush_cache
203
203
  assert_equal 1, @calculator.counter
204
204
 
205
- assert @calculator.instance_variable_get(:@_memoized_counter).any?
205
+ assert @calculator.instance_variable_get(:@_memoized_counter)
206
206
  @calculator.flush_cache(:counter)
207
- assert @calculator.instance_variable_get(:@_memoized_counter).empty?
207
+ assert_nil @calculator.instance_variable_get(:@_memoized_counter)
208
+ assert !@calculator.instance_variable_defined?(:@_memoized_counter)
208
209
 
209
210
  assert_equal 2, @calculator.counter
210
211
  end
@@ -212,9 +213,10 @@ class MemoistTest < Test::Unit::TestCase
212
213
  def test_unmemoize_all
213
214
  assert_equal 1, @calculator.counter
214
215
 
215
- assert @calculator.instance_variable_get(:@_memoized_counter).any?
216
+ assert @calculator.instance_variable_get(:@_memoized_counter)
216
217
  @calculator.unmemoize_all
217
- assert @calculator.instance_variable_get(:@_memoized_counter).empty?
218
+ assert_nil @calculator.instance_variable_get(:@_memoized_counter)
219
+ assert !@calculator.instance_variable_defined?(:@_memoized_counter)
218
220
 
219
221
  assert_equal 2, @calculator.counter
220
222
  end
@@ -329,4 +331,4 @@ class MemoistTest < Test::Unit::TestCase
329
331
  assert_equal 1, person.is_developer_calls
330
332
  end
331
333
 
332
- end
334
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: memoist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Peek
@@ -19,7 +19,7 @@ authors:
19
19
  autorequire:
20
20
  bindir: bin
21
21
  cert_chain: []
22
- date: 2014-04-16 00:00:00.000000000 Z
22
+ date: 2014-06-01 00:00:00.000000000 Z
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency
25
25
  name: bundler