Merb::Cache::PageStore

Store well suited for page caching.

Public Instance Methods

delete(dispatch, parameters = {}) click to toggle source
    # File lib/merb-cache/stores/strategy/page_store.rb, line 43
43:     def delete(dispatch, parameters = {})
44:       if writable?(dispatch, parameters)
45:         @stores.map {|s| s.delete(normalize(dispatch), {})}.any?
46:       end
47:     end
delete_all!() click to toggle source
    # File lib/merb-cache/stores/strategy/page_store.rb, line 49
49:     def delete_all!
50:       @stores.map {|s| s.delete_all!}.all?
51:     end
exists?(dispatch, parameters = {}) click to toggle source
    # File lib/merb-cache/stores/strategy/page_store.rb, line 37
37:     def exists?(dispatch, parameters = {})
38:       if writable?(dispatch, parameters)
39:         @stores.capture_first {|s| s.exists?(normalize(dispatch), {})}
40:       end
41:     end
fetch(dispatch, parameters = {}, conditions = {}, &blk) click to toggle source
    # File lib/merb-cache/stores/strategy/page_store.rb, line 31
31:     def fetch(dispatch, parameters = {}, conditions = {}, &blk)
32:       if writable?(dispatch, parameters, conditions)
33:         read(dispatch, parameters) || @stores.capture_first {|s| s.fetch(normalize(dispatch), data || dispatch.body, {}, conditions, &blk)}
34:       end
35:     end
normalize(dispatch) click to toggle source
    # File lib/merb-cache/stores/strategy/page_store.rb, line 53
53:     def normalize(dispatch)
54:       key = dispatch.request.uri.split('?').first
55:       key << "index" if key =~ /\/$/
56:       key << ".#{dispatch.content_type}" unless key =~ /\.\w{2,6}/
57:       key
58:     end
query_string_present?(dispatch) click to toggle source
    # File lib/merb-cache/stores/strategy/page_store.rb, line 60
60:     def query_string_present?(dispatch)
61:       dispatch.request.env["REQUEST_URI"] == dispatch.request.uri
62:     end
read(dispatch, parameters = {}) click to toggle source
    # File lib/merb-cache/stores/strategy/page_store.rb, line 15
15:     def read(dispatch, parameters = {})
16:       nil
17:     end
writable?(dispatch, parameters = {}, conditions = {}) click to toggle source
    # File lib/merb-cache/stores/strategy/page_store.rb, line 4
 4:     def writable?(dispatch, parameters = {}, conditions = {})
 5:       if Merb::Controller === dispatch && dispatch.request.method == :get &&
 6:           !dispatch.request.uri.nil? && !dispatch.request.uri.empty? &&
 7:           !conditions.has_key?(:if) && !conditions.has_key?(:unless) &&
 8:           query_string_present?(dispatch)
 9:         @stores.any? {|s| s.writable?(normalize(dispatch), parameters, conditions)}
10:       else
11:         false
12:       end
13:     end
write(dispatch, data = nil, parameters = {}, conditions = {}) click to toggle source
    # File lib/merb-cache/stores/strategy/page_store.rb, line 19
19:     def write(dispatch, data = nil, parameters = {}, conditions = {})
20:       if writable?(dispatch, parameters, conditions)
21:         @stores.capture_first {|s| s.write(normalize(dispatch), data || dispatch.body, {}, conditions)}
22:       end
23:     end
write_all(dispatch, data = nil, parameters = {}, conditions = {}) click to toggle source
    # File lib/merb-cache/stores/strategy/page_store.rb, line 25
25:     def write_all(dispatch, data = nil, parameters = {}, conditions = {})
26:       if writable?(dispatch, parameters, conditions)
27:         @stores.map {|s| s.write_all(normalize(dispatch), data || dispatch.body, {}, conditions)}.all?
28:       end
29:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.