Merb::Cache::CacheMixin::ClassMethods

Public Instance Methods

build_request(path, params = {}, env = {}) click to toggle source
    # File lib/merb-cache/merb_ext/controller.rb, line 66
66:     def build_request(path, params = {}, env = {})
67:       path, params, env = nil, path, params if path.is_a? Hash
68: 
69:       Merb::Cache::CacheRequest.new(path, params, env)
70:     end
build_url(*args) click to toggle source
    # File lib/merb-cache/merb_ext/controller.rb, line 72
72:     def build_url(*args)
73:       Merb::Router.url(*args)
74:     end
cache(*actions) click to toggle source
    # File lib/merb-cache/merb_ext/controller.rb, line 12
12:     def cache(*actions)
13:       if actions.last.is_a? Hash
14:         cache_action(*actions)
15:       else
16:         actions.each {|a| cache_action(*a)}
17:       end
18:     end
cache!(conditions = {}) click to toggle source
    # File lib/merb-cache/merb_ext/controller.rb, line 7
 7:     def cache!(conditions = {})
 8:       before(:_cache_before, conditions.only(:if, :unless).merge(:with => conditions))
 9:       after(:_cache_after, conditions.only(:if, :unless).merge(:with => conditions))
10:     end
cache_action(action, conditions = {}) click to toggle source
    # File lib/merb-cache/merb_ext/controller.rb, line 20
20:     def cache_action(action, conditions = {})
21:       before("_cache_#{action}_before", conditions.only(:if, :unless).merge(:with => [conditions], :only => action))
22:       after("_cache_#{action}_after", conditions.only(:if, :unless).merge(:with => [conditions], :only => action))
23:       alias_method "_cache_#{action}_before", :_cache_before
24:       alias_method "_cache_#{action}_after",  :_cache_after
25:     end
eager_cache(trigger_action, target = trigger_action, conditions = {}, &blk) click to toggle source
    # File lib/merb-cache/merb_ext/controller.rb, line 27
27:     def eager_cache(trigger_action, target = trigger_action, conditions = {}, &blk)
28:       target, conditions = trigger_action, target if target.is_a? Hash
29: 
30:       if target.is_a? Array
31:         target_controller, target_action = *target
32:       else
33:         target_controller, target_action = self, target
34:       end
35: 
36:       after("_eager_cache_#{trigger_action}_to_#{target_controller.name.snake_case}__#{target_action}_after", conditions.only(:if, :unless).merge(:with => [target_controller, target_action, conditions, blk], :only => trigger_action))
37:       alias_method "_eager_cache_#{trigger_action}_to_#{target_controller.name.snake_case}__#{target_action}_after", :_eager_cache_after
38:     end
eager_dispatch(action, params = {}, env = {}, blk = nil) click to toggle source
    # File lib/merb-cache/merb_ext/controller.rb, line 40
40:     def eager_dispatch(action, params = {}, env = {}, blk = nil)
41:       kontroller = if blk.nil?
42:         new(Merb::Request.new(env))
43:       else
44:         result = case blk.arity
45:           when 0  then  blk[]
46:           when 1  then  blk[params]
47:           else          blk[*[params, env]]
48:         end
49: 
50:         case result
51:         when NilClass         then new(Merb::Request.new(env))
52:         when Hash, Mash       then new(Merb::Request.new(result))
53:         when Merb::Request    then new(result)
54:         when Merb::Controller then result
55:         else raise ArgumentError, "Block to eager_cache must return nil, the env Hash, a Request object, or a Controller object"
56:         end
57:       end
58: 
59:       kontroller.force_cache!
60: 
61:       kontroller._dispatch(action)
62: 
63:       kontroller
64:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.