module Metova::Responders::HttpCacheResponder
Public Class Methods
new(*)
click to toggle source
Calls superclass method
# File lib/metova/responders/http_cache_responder.rb, line 5 def initialize(*) super @_cache = options.delete :cache end
Public Instance Methods
to_json()
click to toggle source
# File lib/metova/responders/http_cache_responder.rb, line 10 def to_json return if http_cache? and http_cache! to_format end
Private Instance Methods
http_cache!()
click to toggle source
# File lib/metova/responders/http_cache_responder.rb, line 22 def http_cache! controller.fresh_when resource end
http_cache?()
click to toggle source
# File lib/metova/responders/http_cache_responder.rb, line 16 def http_cache? get? and persisted? and ActionController::Base.perform_caching and resource.respond_to?(:cache_key) and (@_cache != false) and controller.params[:cache] != false end
persisted?()
click to toggle source
# File lib/metova/responders/http_cache_responder.rb, line 26 def persisted? resource.respond_to?(:persisted?) ? resource.persisted? : true end