Permalink
Browse files

Refactor cache fragment handling with read/write methods

  • Loading branch information...
1 parent f341acd commit f410c13bf8ec3a8fa3878d8acadb1f3d5a45032c @carlosantoniodasilva carlosantoniodasilva committed Jun 25, 2013
Showing with 6 additions and 6 deletions.
  1. +6 −6 actionview/lib/action_view/helpers/cache_helper.rb
@@ -176,14 +176,14 @@ def fragment_name_with_digest(name) #:nodoc:
# TODO: Create an object that has caching read/write on it
def fragment_for(name = {}, options = nil, &block) #:nodoc:
- if fragment = controller.read_fragment(name, options)
- fragment
- else
- write_fragment_for(name, options, &block)
- end
+ read_fragment_for(name, options) || write_fragment_for(name, options, &block)
+ end
+
+ def read_fragment_for(name, options) #:nodoc:
+ controller.read_fragment(name, options)
end
- def write_fragment_for(name = {}, options = nil, &block) #:nodoc:
+ def write_fragment_for(name, options) #:nodoc:
# VIEW TODO: Make #capture usable outside of ERB
# This dance is needed because Builder can't use capture
pos = output_buffer.length

0 comments on commit f410c13

Please sign in to comment.