fume 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/fume/render_cache.rb +24 -22
  3. metadata +4 -4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.0
1
+ 0.9.1
@@ -30,37 +30,33 @@ module Fume
30
30
  end
31
31
 
32
32
  protected
33
- def render_cache(key, options = {})
34
- if self.class.perform_caching
35
- key = build_render_cache_key(key)
36
- cache = Rails.cache
37
-
38
- fragment = cache.read(key)
39
- if fragment
33
+
34
+ def render_cache(key, options)
35
+ params = self.render_cache_params
36
+
37
+ if params[:cache]
38
+ params[:key] = build_render_cache_key(key)
39
+ params[:options] = options
40
+
41
+ if fragment = params[:cache].read(params[:key])
42
+ params[:key] = nil
43
+
40
44
  response.charset = fragment[:charset]
41
45
  response.content_type = fragment[:content_type]
42
46
  self.response_body = fragment[:body].html_safe
43
- else
44
- yield if block_given?
45
-
46
- self.render_cache_params = {
47
- :key => key,
48
- :options => options,
49
- :cache => cache
50
- }
47
+ return
51
48
  end
52
- else
53
- yield if block_given?
54
49
  end
55
-
50
+
51
+ yield if block_given?
56
52
  end
57
-
53
+
58
54
  def build_render_cache_key(key)
59
55
  base = "render@#{params[:controller]}/#{params[:action]}.#{params[:format]}"
60
56
  key = self.key_to_string(key)
61
57
  "#{base}##{key}"
62
58
  end
63
-
59
+
64
60
  def key_to_string(obj)
65
61
  case obj
66
62
  when nil
@@ -75,13 +71,19 @@ module Fume
75
71
  obj.to_s
76
72
  end
77
73
  end
78
-
79
74
  end
80
75
 
81
76
  class RenderCacheFilter
82
77
  def filter(controller)
78
+ controller.render_cache_params ||= {
79
+ options: {},
80
+ cache: nil
81
+ }
82
+ controller.render_cache_params[:cache] = Rails.cache if controller.class.perform_caching
83
+
83
84
  yield
84
- params = controller.render_cache_params || {}
85
+
86
+ params = controller.render_cache_params
85
87
  if params[:key]
86
88
  content = {
87
89
  :charset => controller.response.charset,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fume
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-06 00:00:00.000000000 Z
12
+ date: 2012-08-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -119,7 +119,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
119
119
  version: '0'
120
120
  segments:
121
121
  - 0
122
- hash: -559507536724635748
122
+ hash: -2374379238819823268
123
123
  required_rubygems_version: !ruby/object:Gem::Requirement
124
124
  none: false
125
125
  requirements:
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
128
  version: '0'
129
129
  segments:
130
130
  - 0
131
- hash: -559507536724635748
131
+ hash: -2374379238819823268
132
132
  requirements: []
133
133
  rubyforge_project:
134
134
  rubygems_version: 1.8.24