# File lib/erector/caching.rb, line 3 def initialize @stores = {} end
# File lib/erector/caching.rb, line 19 def [](klass, params = {}, content_method = nil) store_for(klass)[key(params)][content_method] end
# File lib/erector/caching.rb, line 11 def []=(*args) value = args.pop klass = args.shift params = args.first.is_a?(Hash) ? args.first : {} content_method = args.last.is_a?(Symbol) ? args.last : nil store_for(klass)[key(params)][content_method] = value end
# File lib/erector/caching.rb, line 23 def delete(klass, params = {}) store_for(klass).delete(key(params)) end
# File lib/erector/caching.rb, line 27 def delete_all(klass) @stores.delete(klass) end
convert hash-key to array-key for compatibility with 1.8.6
# File lib/erector/caching.rb, line 32 def key(params) params.to_a end
# File lib/erector/caching.rb, line 7 def store_for(klass) @stores[klass] ||= Hash.new {|h,k| h[k] = {}} end