will_cache 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
data/lib/will_cache/cacheable.rb
CHANGED
@@ -62,7 +62,7 @@ module WillCache
|
|
62
62
|
if with.blank?
|
63
63
|
base
|
64
64
|
else
|
65
|
-
"#{base}:#{with}"
|
65
|
+
"#{base}:#{with.inspect}"
|
66
66
|
end
|
67
67
|
end
|
68
68
|
memoize :method_cache_key
|
@@ -71,7 +71,7 @@ module WillCache
|
|
71
71
|
if with.blank?
|
72
72
|
send(method_name)
|
73
73
|
else
|
74
|
-
send(method_name, with)
|
74
|
+
send(method_name, *with)
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
Binary file
|
@@ -1,7 +1,13 @@
|
|
1
1
|
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
require 'active_support/cache'
|
2
3
|
|
3
4
|
class Rails
|
4
5
|
def self.cache
|
6
|
+
@@cache
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.cache=(c)
|
10
|
+
@@cache = c
|
5
11
|
end
|
6
12
|
end
|
7
13
|
|
@@ -10,6 +16,10 @@ class User < ActiveRecord::Base
|
|
10
16
|
acts_as_cached
|
11
17
|
|
12
18
|
after_update :expire_cache
|
19
|
+
|
20
|
+
def self.sum(a, b)
|
21
|
+
a + b
|
22
|
+
end
|
13
23
|
end
|
14
24
|
|
15
25
|
class Article < ActiveRecord::Base
|
@@ -27,6 +37,7 @@ class WillCacheTest < Test::Unit::TestCase
|
|
27
37
|
|
28
38
|
@user = User.create!
|
29
39
|
@user.articles << Article.new(:body => 'hey')
|
40
|
+
Rails.cache = ActiveSupport::Cache::FileStore.new('tmp')
|
30
41
|
end
|
31
42
|
|
32
43
|
def test_cached_on_class_method
|
@@ -36,6 +47,10 @@ class WillCacheTest < Test::Unit::TestCase
|
|
36
47
|
assert_equal 1, User.cached(:count)
|
37
48
|
end
|
38
49
|
|
50
|
+
def test_cached_on_class_method_with_args
|
51
|
+
assert_equal 5, User.cached(:sum, :with => [2, 3])
|
52
|
+
end
|
53
|
+
|
39
54
|
def test_cached_on_instance_method
|
40
55
|
key = "User:1:articles"
|
41
56
|
mock(Rails.cache).exist?(key) { false }
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: will_cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 15
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 8
|
10
|
+
version: 0.0.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Dejan Simic
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-11-28 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -34,6 +34,7 @@ files:
|
|
34
34
|
- lib/will_cache.rb
|
35
35
|
- test/fixtures/database.yml
|
36
36
|
- test/fixtures/schema.rb
|
37
|
+
- test/functional/tmp/68B/030/User%3Asum%3A%5B2%2C+3%5D
|
37
38
|
- test/functional/will_cache_test.rb
|
38
39
|
- test/test_helper.rb
|
39
40
|
- README.md
|
@@ -67,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
68
|
requirements: []
|
68
69
|
|
69
70
|
rubyforge_project:
|
70
|
-
rubygems_version: 1.
|
71
|
+
rubygems_version: 1.6.2
|
71
72
|
signing_key:
|
72
73
|
specification_version: 3
|
73
74
|
summary: Drop-in replacement for cache_fu that uses Rails.cache store
|