cache_method 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/cache_method.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
19
  s.require_paths = ["lib"]
20
20
 
21
- s.add_dependency 'cache'
21
+ s.add_dependency 'cache', '>=0.1.2'
22
22
  s.add_development_dependency 'memcached'
23
23
  # if RUBY_VERSION >= '1.9'
24
24
  # s.add_development_dependency 'ruby-debug19'
@@ -25,16 +25,16 @@ module CacheMethod
25
25
  #
26
26
  # Example:
27
27
  # CacheMethod.config.storage = Memcached.new '127.0.0.1:11211'
28
- def storage=(raw_client)
29
- if raw_client.is_a?(::Cache)
30
- @storage = raw_client
28
+ def storage=(raw_client_or_nil)
29
+ if raw_client_or_nil.is_a?(::Cache)
30
+ @storage = raw_client_or_nil
31
31
  else
32
- @storage = ::Cache.new raw_client
32
+ @storage = ::Cache.new raw_client_or_nil
33
33
  end
34
34
  end
35
35
 
36
36
  def storage #:nodoc:
37
- @storage || raise("You need to set CacheMethod.config.storage with a cache storage of your choice")
37
+ @storage ||= ::Cache.new
38
38
  end
39
39
 
40
40
  # TTL for method caches. Defaults to 24 hours or 86,400 seconds.
@@ -1,3 +1,3 @@
1
1
  module CacheMethod
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -196,4 +196,26 @@ class TestCacheMethod < Test::Unit::TestCase
196
196
  assert_equal 'danke schoen', Blog2.get_latest_entries
197
197
  assert_equal 2, Blog2.request_count
198
198
  end
199
+
200
+ def test_never_set_storage
201
+ CacheMethod.config.instance_variable_set :@storage, nil
202
+ a = CopyCat1.new 'mimo'
203
+
204
+ assert_equal 'hi', a.echo('hi')
205
+ assert_equal 1, a.echo_count
206
+
207
+ assert_equal 'hi', a.echo('hi')
208
+ assert_equal 1, a.echo_count
209
+ end
210
+
211
+ def test_set_storage_to_nil
212
+ CacheMethod.config.storage = nil
213
+ a = CopyCat1.new 'mimo'
214
+
215
+ assert_equal 'hi', a.echo('hi')
216
+ assert_equal 1, a.echo_count
217
+
218
+ assert_equal 'hi', a.echo('hi')
219
+ assert_equal 1, a.echo_count
220
+ end
199
221
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cache_method
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Seamus Abshere
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-23 00:00:00 -06:00
18
+ date: 2011-02-24 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -26,10 +26,12 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- hash: 3
29
+ hash: 31
30
30
  segments:
31
31
  - 0
32
- version: "0"
32
+ - 1
33
+ - 2
34
+ version: 0.1.2
33
35
  type: :runtime
34
36
  version_requirements: *id001
35
37
  - !ruby/object:Gem::Dependency