cache_key_for 0.1.4 → 0.1.5

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: fa530d7de98c487c76f960631c3bd8e0a613e2b6
4
- data.tar.gz: 97349e29bff79a5c3af955dfb40668d20e12298b
3
+ metadata.gz: be19aeb37e5ce9fe0c973ed15bad9dc39a373401
4
+ data.tar.gz: 86b011411d5d4e2c6c7b22e4a3f3e876d1315c7b
5
5
  SHA512:
6
- metadata.gz: 64843b44e66b258029416301ade6457d28d3b9fea3d4dc9c2a98a101ea03acbfd08a3cbcb8c422e871176f0c14f0b27fc0825ddace080402490bfd5690546c7a
7
- data.tar.gz: cad248d347208d8d080e5fc5a3cd9ffc10a884d3079c8a3d0a0ead2869fdc2c6eed756f44cbe9ed8d6618590c8ee1f385de4b88ffa1b885933743b43f41222e0
6
+ metadata.gz: ac6ebf416b422bc8b36d180e4a7c3ae119003581a201c5b80349b16a2b86f60d4cc7902adf7c4315defaf65ad7ccab077a522e323f915e7cf38ec3a22149f645
7
+ data.tar.gz: c4ca22868d6475660266f45575cd44296a8f5d3216ae7d009f6f83a42d642a74c46b306e24e41de5bb317378016f31466086d38e21fbaefe26d982e4bb61225e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cache_key_for (0.1.4)
4
+ cache_key_for (0.1.5)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -86,3 +86,7 @@ app_name:views/en/datacenters/5bd92bd352e7726d02175752913014711f5d412e/companies
86
86
 
87
87
  rm gemfiles/*.lock
88
88
  bundle exec appraisal install
89
+
90
+ ## Todo
91
+
92
+ * implement https://robots.thoughtbot.com/ruby-2-keyword-arguments to simplify passing custom args
@@ -43,9 +43,19 @@
43
43
  # ```
44
44
  module CacheKeyForHelper
45
45
  def cache_key_for(scoped_collection, collection_prefix, cache_owner_cache_key = '', suffix = '', whitelist_params = [], default_params = {})
46
- max_updated_at = scoped_collection.to_a.map { |i| i.updated_at ? i.updated_at.utc.to_f : 0 }.max
46
+ if scoped_collection.respond_to?(:maximum)
47
+ max_updated_at = scoped_collection.maximum(:updated_at).to_f
48
+ elsif scoped_collection.class == Array
49
+ max_updated_at = scoped_collection.to_a.map { |i| i.updated_at ? i.updated_at.utc.to_f : 0 }.max
50
+ elsif scoped_collection.respond_to?(:max)
51
+ max_updated_at = scoped_collection.max(:updated_at).to_f
52
+ end
47
53
  count = scoped_collection.count
48
- ids_string = scoped_collection.to_a.map(&:id).join('-')
54
+ if scoped_collection.respond_to?(:ids)
55
+ ids_string = scoped_collection.ids
56
+ else
57
+ ids_string = scoped_collection.to_a.map(&:id).join('-')
58
+ end
49
59
  blacklist_params = ['utm_source', 'utm_medium', 'utm_term', 'utm_content', 'utm_campaign']
50
60
  request_params = if request.params
51
61
  if whitelist_params.empty?
@@ -1,3 +1,3 @@
1
1
  module CacheKeyFor
2
- VERSION = '0.1.4'.freeze
2
+ VERSION = '0.1.5'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cache_key_for
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcin Kalita
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-16 00:00:00.000000000 Z
11
+ date: 2016-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: appraisal