Module: Sparkle::Controller

Defined in:
lib/sparkle/controller.rb

Instance Method Summary collapse

Instance Method Details

#fetchObject



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/sparkle/controller.rb', line 4

def fetch
  cache_entry = Rails.cache.read(params[:key])
  partial = cache_entry[:partial]
  locals = cache_entry[:locals]
  begin
    locals.values.each { |value| value._sparkle_refresh! if value.class.include?(Refreshable) }
  rescue Exception => e
    session[:sparkle_exception] = e
  end
  render :partial => partial, :locals => locals.merge(:sparkle_cache_key => nil)
  raise session.delete(:sparkle_exception) if session[:sparkle_exception]
end