# File lib/merb-cache/merb_ext/controller.rb, line 114 114: def _cache_after(conditions = {}) 115: if @_skip_cache.nil? && Merb::Cache[_lookup_store(conditions)].write(self, nil, *_parameters_and_conditions(conditions)) 116: @_cache_write = true 117: end 118: end
# File lib/merb-cache/merb_ext/controller.rb, line 105 105: def _cache_before(conditions = {}) 106: unless @_force_cache 107: if @_skip_cache.nil? && data = Merb::Cache[_lookup_store(conditions)].read(self, _parameters_and_conditions(conditions).first) 108: throw(:halt, data) 109: @_cache_hit = true 110: end 111: end 112: end
# File lib/merb-cache/merb_ext/controller.rb, line 120 120: def _eager_cache_after(klass, action, conditions = {}, blk = nil) 121: if @_skip_cache.nil? 122: run_later do 123: controller = klass.eager_dispatch(action, request.params.dup, request.env.dup, blk) 124: 125: Merb::Cache[controller._lookup_store(conditions)].write(controller, nil, *controller._parameters_and_conditions(conditions)) 126: end 127: end 128: end
# File lib/merb-cache/merb_ext/controller.rb, line 156 156: def _lookup_store(conditions = {}) 157: conditions[:store] || conditions[:stores] || default_cache_store 158: end
ugly, please make me purdy’er
# File lib/merb-cache/merb_ext/controller.rb, line 166 166: def _parameters_and_conditions(conditions) 167: parameters = {} 168: 169: if self.class.respond_to? :action_argument_list 170: arguments, defaults = self.class.action_argument_list[action_name] 171: arguments.inject(parameters) do |parameters, arg| 172: if defaults.include?(arg.first) 173: parameters[arg.first] = self.params[arg.first] || arg.last 174: else 175: parameters[arg.first] = self.params[arg.first] 176: end 177: parameters 178: end 179: end 180: 181: case conditions[:params] 182: when Symbol 183: parameters[conditions[:params]] = self.params[conditions[:params]] 184: when Array 185: conditions[:params].each do |param| 186: parameters[param] = self.params[param] 187: end 188: end 189: 190: return parameters, conditions.except(:params, :store, :stores) 191: end
# File lib/merb-cache/merb_ext/controller.rb, line 144 144: def _set_skip_cache 145: @_skip_cache = true 146: end
Overwrite this in your controller to change the default store for a given controller
# File lib/merb-cache/merb_ext/controller.rb, line 161 161: def default_cache_store 162: Merb::Cache.default_store_name 163: end
# File lib/merb-cache/merb_ext/controller.rb, line 130 130: def eager_cache(action, conditions = {}, params = request.params.dup, env = request.env.dup, &blk) 131: unless @_skip_cache 132: if action.is_a?(Array) 133: klass, action = *action 134: else 135: klass = self.class 136: end 137: 138: run_later do 139: controller = klass.eager_dispatch(action, params.dup, env.dup, blk) 140: end 141: end 142: end
# File lib/merb-cache/merb_ext/controller.rb, line 93 93: def fetch_fragment(opts = {}, conditions = {}, &proc) 94: 95: if opts[:cache_key].blank? 96: file, line = proc.to_s.scan(%{^#<Proc:0x\w+@(.+):(\d+)>$}).first 97: fragment_key = "#{file}[#{line}]" 98: else 99: fragment_key = opts.delete(:cache_key) 100: end 101: 102: concat(Merb::Cache[_lookup_store(conditions)].fetch(fragment_key, opts, conditions) { capture(&proc) }, proc.binding) 103: end
# File lib/merb-cache/merb_ext/controller.rb, line 77 77: def fetch_partial(template, opts={}, conditions = {}) 78: template_id = template.to_s 79: if template_id =~ %{^/} 80: template_path = File.dirname(template_id) / "_#{File.basename(template_id)}" 81: else 82: kontroller = (m = template_id.match(/.*(?=\/)/)) ? m[0] : controller_name 83: template_id = "_#{File.basename(template_id)}" 84: end 85: 86: unused, template_key = _template_for(template_id, opts.delete(:format) || content_type, kontroller, template_path) 87: 88: fetch_proc = lambda { partial(template, opts) } 89: 90: concat(Merb::Cache[_lookup_store(conditions)].fetch(template_key, opts, conditions, &fetch_proc), fetch_proc.binding) 91: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.