Skip to content

Instantly share code, notes, and snippets.

@benburkert
Created July 29, 2008 06:08
Show Gist options
  • Save benburkert/3032 to your computer and use it in GitHub Desktop.
Save benburkert/3032 to your computer and use it in GitHub Desktop.
def eager_cache(trigger_action, target_action, conditions = {})
if target_action.is_a? Array
target_controller, target_action = *target_action
conditions[:controller] = target_controller
end
after("_eager_cache_#{trigger_action}_after", conditions.only(:if, :unless).merge(:with => [conditions.except(:if, :unless)], :only => trigger_action))
alias_method "_eager_cache_#{trigger_action}_after", :_eager_cache_after
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment