aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/caching
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2008-06-24 11:53:49 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2008-06-24 11:53:49 -0700
commit69e72af62261dd8971890711b51c6eef2c68bc71 (patch)
treef80e7b0ae2d0f22ef345ad38eac2f1e3b7c34179 /actionpack/lib/action_controller/caching
parentf6520b7dc7e460c62ba36dc761e39480bf77fe83 (diff)
downloadrails-69e72af62261dd8971890711b51c6eef2c68bc71.tar.gz
rails-69e72af62261dd8971890711b51c6eef2c68bc71.tar.bz2
rails-69e72af62261dd8971890711b51c6eef2c68bc71.zip
Improve readability
Diffstat (limited to 'actionpack/lib/action_controller/caching')
-rw-r--r--actionpack/lib/action_controller/caching/fragments.rb18
1 files changed, 10 insertions, 8 deletions
diff --git a/actionpack/lib/action_controller/caching/fragments.rb b/actionpack/lib/action_controller/caching/fragments.rb
index e4f5de44ab..57b31ec9d1 100644
--- a/actionpack/lib/action_controller/caching/fragments.rb
+++ b/actionpack/lib/action_controller/caching/fragments.rb
@@ -61,16 +61,18 @@ module ActionController #:nodoc:
end
def fragment_for(block, name = {}, options = nil) #:nodoc:
- unless perform_caching then block.call; return end
-
- buffer = yield
-
- if cache = read_fragment(name, options)
- buffer.concat(cache)
+ if perform_caching
+ buffer = yield
+
+ if cache = read_fragment(name, options)
+ buffer.concat(cache)
+ else
+ pos = buffer.length
+ block.call
+ write_fragment(name, buffer[pos..-1], options)
+ end
else
- pos = buffer.length
block.call
- write_fragment(name, buffer[pos..-1], options)
end
end