action_param_caching 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35e4faa5c154d84293cc12b12e1835a5dc10d516
|
4
|
+
data.tar.gz: dce5f7b4583f52dbd22c8f9c718b25369684f6f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebfb09d03f19638197d1d59c3056236f95490b24fbac332e4bfc922313622bc349f5c398fae8099f9b88489d3eacff49e3e5ebe090855e07eccc47b529a6cf88
|
7
|
+
data.tar.gz: 1b5d612c40ef423c64bc4ceb6a2506af8c396daf624cf23f025081045d2264f8753fed49ab1432f5f6701899875530d3561565b629eb769f8440eb030ca781ce
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# ActionParamCaching
|
2
2
|
|
3
|
-
Action param caching
|
3
|
+
Action param caching simplifies action caching based on parameter values. It allows you to quickly specify what actions you want to cache base on the parameters they are passed, the set of parameters you are interested in caching on, and an option prefix value for ignoring parameters that are designed to bust your cache.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -22,7 +22,7 @@ Or install it yourself as:
|
|
22
22
|
2. Require 'action_param_caching'
|
23
23
|
3. Add 'extend ActionParamCaching::Rails::ActionController' to your controller
|
24
24
|
4. Add the correct param cache statement to your controller.
|
25
|
-
- Standard statement for full param
|
25
|
+
- Standard statement for full param caching:
|
26
26
|
cache_with_params :on => [:index]
|
27
27
|
- Cache on a set or subset
|
28
28
|
cache_with_params :on => [:index], :with_set_or_subset => [:param1, :param2]
|
@@ -3,11 +3,27 @@ module ActionParamCaching
|
|
3
3
|
attr_reader :action, :valid_params, :filter_starting_with, :argz
|
4
4
|
attr_accessor :did_config_cache
|
5
5
|
|
6
|
-
def
|
6
|
+
def self.store_lookup(controller, action, config)
|
7
|
+
@lookup = {} if @lookup.nil?
|
8
|
+
@lookup[controller] = {} if @lookup[controller].nil?
|
9
|
+
@lookup[controller][action] = config
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.lookup
|
13
|
+
@lookup
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(controller_path, action, valid_params = [], filter_starting_with = nil)
|
7
17
|
@action = action
|
8
|
-
|
18
|
+
if valid_params
|
19
|
+
@valid_params = valid_params
|
20
|
+
@valid_params << :controller << :action << :format
|
21
|
+
end
|
9
22
|
@filter_starting_with = filter_starting_with
|
23
|
+
@filter_starting_with ||= '_'
|
10
24
|
@did_config_cache = false
|
25
|
+
|
26
|
+
ActionParamCaching::ActionConfig.store_lookup(controller_path, action, self)
|
11
27
|
end
|
12
28
|
|
13
29
|
def cache_args
|
@@ -27,15 +43,19 @@ module ActionParamCaching
|
|
27
43
|
end
|
28
44
|
|
29
45
|
def filtered_path_proc
|
30
|
-
Proc.new { |request|
|
46
|
+
Proc.new { |request|
|
47
|
+
request.params.delete_if { |k,v| k.to_s.start_with?(
|
48
|
+
ActionParamCaching::ActionConfig.lookup[request.params[:controller]][request.params[:action].to_sym].filter_starting_with) }.to_query }
|
31
49
|
end
|
32
50
|
|
33
51
|
def path_proc
|
34
|
-
Proc.new { |request| params.to_query }
|
52
|
+
Proc.new { |request| request.params.to_query }
|
35
53
|
end
|
36
54
|
|
37
55
|
def if_proc
|
38
|
-
Proc.new {
|
56
|
+
Proc.new { |request|
|
57
|
+
request.params.collect{|key, value| ActionParamCaching::ActionConfig.lookup[request.params[:controller]][request.params[:action].to_sym].valid_params.include?(key.to_sym) ||
|
58
|
+
key.to_s.start_with?(ActionParamCaching::ActionConfig.lookup[request.params[:controller]][request.params[:action].to_sym].filter_starting_with)}.all? }
|
39
59
|
end
|
40
60
|
end
|
41
61
|
end
|
@@ -7,7 +7,7 @@ module ActionParamCaching
|
|
7
7
|
@action_cache_configs = {} if @action_cache_configs.nil?
|
8
8
|
|
9
9
|
options[:on].each do |action|
|
10
|
-
@action_cache_configs[action] = ActionParamCaching::ActionConfig.new(action, options[:with_set_or_subset], options[:filter_starting_with]) unless @action_cache_configs[action]
|
10
|
+
@action_cache_configs[action] = ActionParamCaching::ActionConfig.new(self.controller_path, action, options[:with_set_or_subset], options[:filter_starting_with]) unless @action_cache_configs[action]
|
11
11
|
end
|
12
12
|
|
13
13
|
options[:on].each do |action|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: action_param_caching
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- cparratto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|