osbridge/openconferenceware

View on GitHub
app/helpers/open_conference_ware/cache_if_helper.rb

Summary

Maintainability
A
0 mins
Test Coverage
module OpenConferenceWare
  module CacheIfHelper
    # Caches +block+ in view only if the +condition+ is true.
    # http://skionrails.wordpress.com/2008/05/22/conditional-fragment-caching/
    def cache_if(condition, name={}, &block)
      if condition
        cache(name, &block)
      else
        block.call
      end
    end
  end
end