action_param_caching 0.0.5 → 0.0.6

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: af2efb7d4b2e8e93e987c154450467fc5a6cd033
4
- data.tar.gz: 54c135c51ef4f9675ef95972ebfdee17179dc605
3
+ metadata.gz: 764ab0a770e71c1520a4662e70dc40c1eaac2876
4
+ data.tar.gz: 410bf7243c71ced0e53af0c452f31ff324ad2898
5
5
  SHA512:
6
- metadata.gz: 33378ceee82abfb723d4a21cba13eb61adb0a40946107b20d7314506d45e55e7d048231de2fe381e1e022f86b02655c7fe38bc67a02fc4e6dbafaa3894c88ad9
7
- data.tar.gz: e79cae2094f1ae7845b356489854ba459c187e7f85081e90b7bdff8e67f836e5fc3a9a31db371cd8367f54512e349772404299ca29efd4a688e67e13b7fb1cf1
6
+ metadata.gz: 8c05eda07bb4b683d9a137db270621a62f4dd3e45b9bb24de5d5e09201fffdbf903a215fe040bca3f26b798eaa2835f53584d32e29dcb382a5ec768d5c686cb9
7
+ data.tar.gz: 3af187e242a0cd8a0c3188b1d5b84da310be973d7d387dda18569a3e06cc9b066fb63e02c954e24d7591e2b6a80bbd7b3840f568c6efd0f2fa2c1d977368af53
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # ActionParamCaching
1
+ # ActionParamCaching [![Build Status](https://travis-ci.org/pennymac/action_param_caching.png?branch=master)](https://travis-ci.org/pennymac/action_param_caching)
2
2
 
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.
3
+ Action param caching simplifies action caching based on parameter values. It allows you to quickly specify what actions you want to cache based 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
 
@@ -28,6 +28,8 @@ Or install it yourself as:
28
28
  cache_with_params :on => [:index], :with_set_or_subset => [:param1, :param2]
29
29
  - Ignore params with prefix
30
30
  cache_with_params :on => [:index], :filter_starting_with => '_'
31
+ - Expiring Cache
32
+ cache_with_params :on => [:index], :expires_in => 24.hours
31
33
 
32
34
  ## Contributing
33
35
 
@@ -1,6 +1,6 @@
1
1
  module ActionParamCaching
2
2
  class ActionConfig
3
- attr_reader :action, :valid_params, :filter_starting_with, :argz
3
+ attr_reader :action, :valid_params, :filter_starting_with, :argz, :expires_in
4
4
  attr_accessor :did_config_cache
5
5
 
6
6
  def self.store_lookup(controller, action, config)
@@ -13,7 +13,7 @@ module ActionParamCaching
13
13
  @lookup
14
14
  end
15
15
 
16
- def initialize(controller_path, action, valid_params = [], filter_starting_with = nil)
16
+ def initialize(controller_path, action, valid_params = [], filter_starting_with = nil, expires_in = nil)
17
17
  @action = action
18
18
  if valid_params and !valid_params.empty?
19
19
  @valid_params = valid_params
@@ -22,6 +22,7 @@ module ActionParamCaching
22
22
  @filter_starting_with = filter_starting_with
23
23
  @filter_starting_with ||= '_'
24
24
  @did_config_cache = false
25
+ @expires_in = expires_in
25
26
 
26
27
  ActionParamCaching::ActionConfig.store_lookup(controller_path, action, self)
27
28
  end
@@ -39,6 +40,10 @@ module ActionParamCaching
39
40
  @argz[:cache_path] = self.path_proc
40
41
  end
41
42
 
43
+ if @expires_in
44
+ @argz[:expires_in] = self.expires_in
45
+ end
46
+
42
47
  @argz
43
48
  end
44
49
 
@@ -58,4 +63,4 @@ module ActionParamCaching
58
63
  key.to_s.start_with?(ActionParamCaching::ActionConfig.lookup[request.params[:controller]][request.params[:action].to_sym].filter_starting_with)}.all? }
59
64
  end
60
65
  end
61
- end
66
+ 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(self.controller_path, 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], options[:expires_in]) unless @action_cache_configs[action]
11
11
  end
12
12
 
13
13
  options[:on].each do |action|
@@ -18,7 +18,11 @@ module ActionParamCaching
18
18
  config.did_config_cache = true
19
19
  end
20
20
  end
21
+
22
+ if options[:expires_in]
23
+ caches_action :expires_in => options[:expires_in]
24
+ end
21
25
  end
22
26
  end
23
27
  end
24
- end
28
+ end
@@ -1,3 +1,3 @@
1
1
  module ActionParamCaching
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -79,6 +79,14 @@ module ActionParamCaching
79
79
  proc = cache_args[:if]
80
80
  proc.call(request).should be_false
81
81
  end
82
+
83
+ it "adds expires in parameter to action arguments" do
84
+ cache_config = ActionParamCaching::ActionConfig.new("some_controller", :index, [:id, :name, :amount], nil, 24.hours)
85
+ cache_args = cache_config.cache_args
86
+ request = mock
87
+ request.stubs(:params).returns( {:id => 23, :name => "test", :not => "valid", :controller => "some_controller", :action => :index, :format => 'json', :expires_in => 24.hours} )
88
+ cache_args[:expires_in].should eq(24.hours)
89
+ end
82
90
  end
83
91
  end
84
- end
92
+ end
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.5
4
+ version: 0.0.6
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-21 00:00:00.000000000 Z
11
+ date: 2013-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler