cached_resource 2.1.2 → 2.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -99,7 +99,9 @@ Sit back and relax! If you need to reload a particular request you can pass `:re
99
99
  ## Feedback/Problems
100
100
  Feedback is greatly appreciated! Check out this project's [issue tracker](https://github.com/Ahsizara/cached_resource/issues) if you've got anything to say.
101
101
 
102
- ## Future Work
102
+ ## Future Considerations
103
103
  This may change at any time.
104
104
 
105
105
  * Consider checksums to improve the determination of freshness/changédness
106
+ * Callbacks on before and after reload
107
+
@@ -81,7 +81,9 @@ module CachedResource
81
81
  # The key is processed to make sure it is valid.
82
82
  def cache_read(key)
83
83
  key = cache_key(Array(key)) unless key.is_a? String
84
- object = cached_resource.cache.read(key).try(:dup)
84
+ object = cached_resource.cache.read(key).try do |cache|
85
+ cache.dup.tap { |o| o.instance_variable_set(:@persisted, cache.persisted?) if cache.respond_to?(:persisted?) }
86
+ end
85
87
  object && cached_resource.logger.info("#{CachedResource::Configuration::LOGGER_PREFIX} READ #{key}")
86
88
  object
87
89
  end
@@ -102,4 +104,4 @@ module CachedResource
102
104
 
103
105
  end
104
106
  end
105
- end
107
+ end
@@ -1,3 +1,3 @@
1
1
  module CachedResource
2
- VERSION = "2.1.2"
2
+ VERSION = "2.1.3"
3
3
  end
@@ -40,6 +40,12 @@ describe CachedResource do
40
40
  Thing.cached_resource.cache.read("thing/1").should == result
41
41
  end
42
42
 
43
+ it "should cache a response with the same persistence" do
44
+ result1 = Thing.find(1)
45
+ result2 = Thing.find(1)
46
+ result1.persisted?.should == result2.persisted?
47
+ end
48
+
43
49
  it "should read a response when the request is made again" do
44
50
  # make a request
45
51
  Thing.find(1)
@@ -266,4 +272,4 @@ describe CachedResource do
266
272
  new_result.name.should_not == old_result.name
267
273
  end
268
274
  end
269
- end
275
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cached_resource
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 2.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-06 00:00:00.000000000 Z
12
+ date: 2012-04-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: !ruby/object:Gem::Requirement
16
+ requirement: &70187395309820 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,15 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
24
+ version_requirements: *70187395309820
30
25
  - !ruby/object:Gem::Dependency
31
26
  name: activeresource
32
- requirement: !ruby/object:Gem::Requirement
27
+ requirement: &70187395309180 !ruby/object:Gem::Requirement
33
28
  none: false
34
29
  requirements:
35
30
  - - ! '>='
@@ -37,15 +32,10 @@ dependencies:
37
32
  version: '0'
38
33
  type: :runtime
39
34
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
35
+ version_requirements: *70187395309180
46
36
  - !ruby/object:Gem::Dependency
47
37
  name: activesupport
48
- requirement: !ruby/object:Gem::Requirement
38
+ requirement: &70187395308540 !ruby/object:Gem::Requirement
49
39
  none: false
50
40
  requirements:
51
41
  - - ! '>='
@@ -53,15 +43,10 @@ dependencies:
53
43
  version: '0'
54
44
  type: :runtime
55
45
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
46
+ version_requirements: *70187395308540
62
47
  - !ruby/object:Gem::Dependency
63
48
  name: rspec
64
- requirement: !ruby/object:Gem::Requirement
49
+ requirement: &70187395333700 !ruby/object:Gem::Requirement
65
50
  none: false
66
51
  requirements:
67
52
  - - ! '>='
@@ -69,12 +54,7 @@ dependencies:
69
54
  version: '0'
70
55
  type: :development
71
56
  prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: '0'
57
+ version_requirements: *70187395333700
78
58
  description: Enables request-based caching for ActiveResource
79
59
  email: email@suspi.net
80
60
  executables: []
@@ -119,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
99
  version: '0'
120
100
  requirements: []
121
101
  rubyforge_project:
122
- rubygems_version: 1.8.21
102
+ rubygems_version: 1.8.15
123
103
  signing_key:
124
104
  specification_version: 3
125
105
  summary: Caching for ActiveResource
@@ -128,4 +108,3 @@ test_files:
128
108
  - spec/cached_resource/configuration_spec.rb
129
109
  - spec/cached_resource/nilio_spec.rb
130
110
  - spec/spec_helper.rb
131
- has_rdoc: