identity_cache 0.2.3 → 0.2.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: 9ae6ab233ca71a68a76c92e46a6819af91b02c39
4
- data.tar.gz: 1bf83f15e3957a5b20133cdad5cc80d675496973
3
+ metadata.gz: abed676c785bc468fee7349b8e28af469499b78b
4
+ data.tar.gz: e64ed12cef1b57634416a2d4183313fae2a5f491
5
5
  SHA512:
6
- metadata.gz: 45ad03a05a496eccb4327ae9ba775174cbf520a25c0087119fcde8de95ec7e77be79b0ab2dd65fcb99ad588af18d8b1992f126551e04daf58bca28d5a0f5c466
7
- data.tar.gz: 6e9ecd4f00f97adf917e0ad354cb3cadba716b44dd75fd27d95c9437f564ea70af73312841bb89291b0a4beb5310d87538664b5930e2f572566013ac67b04e25
6
+ metadata.gz: cd1e569f94285089975e400da50e183731115c186b538ad822edf0bcb6bdf50c6b152a3b159d4196bb5749cd793f3745b19d744821e96479ba5106a1703d3785
7
+ data.tar.gz: 45358caea4c1d9ef27a682736cf180cbe982a9ce48946b842c6f788d0cb31c47658ed478f2c056e8e736b71e78dfa9af08abdbc5989e99ef12a96450a0197a3e
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.1.1
1
+ 2.2.2
data/.travis.yml CHANGED
@@ -3,7 +3,8 @@ language: ruby
3
3
  rvm:
4
4
  - 1.9.3
5
5
  - 2.0.0
6
- - 2.1.1
6
+ - 2.1
7
+ - 2.2
7
8
 
8
9
  gemfile:
9
10
  - Gemfile.rails32
data/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # IdentityCache changelog
2
2
 
3
- #### Unreleased
3
+ #### 0.2.3
4
4
 
5
5
  - PostgreSQL support
6
6
  - Rails 4.2 compatibility
data/Gemfile.rails42 CHANGED
@@ -1,5 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
  gemspec
3
3
 
4
- gem 'activerecord', '~> 4.2.0.rc1'
5
- gem 'activesupport', '~> 4.2.0.rc1'
4
+ gem 'activerecord', '~> 4.2.0'
5
+ gem 'activesupport', '~> 4.2.0'
data/README.md CHANGED
@@ -221,4 +221,4 @@ IdentityCache is also very much _opt-in_ by deliberate design. This means Identi
221
221
 
222
222
  - JRuby will not work with this current version, as we are using the memcached gem internally to interface with memcache.
223
223
  - See CHANGELOG.md for a list of changes to the library over time.
224
- - The librray is MIT licensed and we welcome contributions. See CONTRIBUTING.md for more information.
224
+ - The library is MIT licensed and we welcome contributions. See CONTRIBUTING.md for more information.
@@ -9,18 +9,22 @@ module IdentityCache
9
9
 
10
10
  module ClassMethods
11
11
  def cache_belongs_to(association, options = {})
12
- self.cached_belongs_tos[association] = options
12
+ raise NotImplementedError if options[:embed]
13
13
 
14
- options[:embed] ||= false
15
- options[:cached_accessor_name] ||= "fetch_#{association}"
16
- options[:foreign_key] ||= reflect_on_association(association).foreign_key
17
- options[:association_class] ||= reflect_on_association(association).klass
18
- options[:prepopulate_method_name] ||= "prepopulate_fetched_#{association}"
19
- if options[:embed]
20
- raise NotImplementedError
21
- else
22
- build_normalized_belongs_to_cache(association, options)
14
+ unless association_reflection = reflect_on_association(association)
15
+ raise AssociationError, "Association named '#{association}' was not found on #{self.class}"
23
16
  end
17
+
18
+ options = {}
19
+ self.cached_belongs_tos[association] = options
20
+
21
+ options[:embed] = false
22
+ options[:cached_accessor_name] = "fetch_#{association}"
23
+ options[:foreign_key] = association_reflection.foreign_key
24
+ options[:association_class] = association_reflection.klass
25
+ options[:prepopulate_method_name] = "prepopulate_fetched_#{association}"
26
+
27
+ build_normalized_belongs_to_cache(association, options)
24
28
  end
25
29
 
26
30
  def build_normalized_belongs_to_cache(association, options)
@@ -24,12 +24,15 @@ module IdentityCache
24
24
 
25
25
  module ClassMethods
26
26
  def rails_cache_key(id)
27
- "#{rails_cache_key_prefix}#{id}"
27
+ "#{prefixed_rails_cache_key}#{id}"
28
28
  end
29
29
 
30
30
  def rails_cache_key_prefix
31
31
  @rails_cache_key_prefix ||= IdentityCache::CacheKeyGeneration.denormalized_schema_hash(self)
32
- "#{rails_cache_key_namespace}blob:#{base_class.name}:#{@rails_cache_key_prefix}:"
32
+ end
33
+
34
+ def prefixed_rails_cache_key
35
+ "#{rails_cache_key_namespace}blob:#{base_class.name}:#{rails_cache_key_prefix}:"
33
36
  end
34
37
 
35
38
  def rails_cache_index_key_for_fields_and_values(fields, values)
@@ -94,10 +94,13 @@ module IdentityCache
94
94
  # * inverse_name: The name of the parent in the association if the name is
95
95
  # not the lowercase pluralization of the parent object's class
96
96
  def cache_has_many(association, options = {})
97
+ options = options.slice(:embed, :inverse_name)
97
98
  options[:embed] = :ids unless options.has_key?(:embed)
98
99
  deprecate_embed_option(options, false, :ids)
99
100
  options[:inverse_name] ||= self.name.underscore.to_sym
100
- raise InverseAssociationError unless self.reflect_on_association(association)
101
+ unless self.reflect_on_association(association)
102
+ raise AssociationError, "Association named '#{association}' was not found on #{self.class}"
103
+ end
101
104
  self.cached_has_manys[association] = options
102
105
 
103
106
  case options[:embed]
@@ -132,9 +135,12 @@ module IdentityCache
132
135
  # necessary if the name is not the lowercase pluralization of the
133
136
  # parent object's class)
134
137
  def cache_has_one(association, options = {})
138
+ options = options.slice(:embed, :inverse_name)
135
139
  options[:embed] = true unless options.has_key?(:embed)
136
140
  options[:inverse_name] ||= self.name.underscore.to_sym
137
- raise InverseAssociationError unless self.reflect_on_association(association)
141
+ unless self.reflect_on_association(association)
142
+ raise AssociationError, "Association named '#{association}' was not found on #{self.class}"
143
+ end
138
144
  self.cached_has_ones[association] = options
139
145
 
140
146
  if options[:embed] == true
@@ -201,10 +207,10 @@ module IdentityCache
201
207
  end
202
208
 
203
209
  def build_recursive_association_cache(association, options) #:nodoc:
204
- options[:association_class] ||= reflect_on_association(association).klass
205
- options[:cached_accessor_name] ||= "fetch_#{association}"
206
- options[:records_variable_name] ||= "cached_#{association}"
207
- options[:population_method_name] ||= "populate_#{association}_cache"
210
+ options[:association_class] = reflect_on_association(association).klass
211
+ options[:cached_accessor_name] = "fetch_#{association}"
212
+ options[:records_variable_name] = "cached_#{association}"
213
+ options[:population_method_name] = "populate_#{association}_cache"
208
214
 
209
215
 
210
216
  unless instance_methods.include?(options[:cached_accessor_name].to_sym)
@@ -218,20 +224,21 @@ module IdentityCache
218
224
  end
219
225
  CODE
220
226
 
221
- add_parent_expiry_hook(options.merge(:only_on_foreign_key_change => false))
227
+ options[:only_on_foreign_key_change] = false
228
+ add_parent_expiry_hook(options)
222
229
  end
223
230
  end
224
231
 
225
232
  def build_id_embedded_has_many_cache(association, options) #:nodoc:
226
233
  singular_association = association.to_s.singularize
227
- options[:association_class] ||= reflect_on_association(association).klass
228
- options[:cached_accessor_name] ||= "fetch_#{association}"
229
- options[:ids_name] ||= "#{singular_association}_ids"
230
- options[:cached_ids_name] ||= "fetch_#{options[:ids_name]}"
231
- options[:ids_variable_name] ||= "cached_#{options[:ids_name]}"
232
- options[:records_variable_name] ||= "cached_#{association}"
233
- options[:population_method_name] ||= "populate_#{association}_cache"
234
- options[:prepopulate_method_name] ||= "prepopulate_fetched_#{association}"
234
+ options[:association_class] = reflect_on_association(association).klass
235
+ options[:cached_accessor_name] = "fetch_#{association}"
236
+ options[:ids_name] = "#{singular_association}_ids"
237
+ options[:cached_ids_name] = "fetch_#{options[:ids_name]}"
238
+ options[:ids_variable_name] = "cached_#{options[:ids_name]}"
239
+ options[:records_variable_name] = "cached_#{association}"
240
+ options[:population_method_name] = "populate_#{association}_cache"
241
+ options[:prepopulate_method_name] = "prepopulate_fetched_#{association}"
235
242
 
236
243
  self.class_eval(<<-CODE, __FILE__, __LINE__ + 1)
237
244
  attr_reader :#{options[:ids_variable_name]}
@@ -260,7 +267,8 @@ module IdentityCache
260
267
  end
261
268
  CODE
262
269
 
263
- add_parent_expiry_hook(options.merge(:only_on_foreign_key_change => true))
270
+ options[:only_on_foreign_key_change] = true
271
+ add_parent_expiry_hook(options)
264
272
  end
265
273
 
266
274
  def attribute_dynamic_fetcher(attribute, fields, values) #:nodoc:
@@ -1,4 +1,4 @@
1
1
  module IdentityCache
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  CACHE_VERSION = 5
4
4
  end
@@ -21,6 +21,7 @@ module IdentityCache
21
21
  DELETED_TTL = 1000
22
22
 
23
23
  class AlreadyIncludedError < StandardError; end
24
+ class AssociationError < StandardError; end
24
25
  class InverseAssociationError < StandardError
25
26
  def initialize
26
27
  super "Inverse name for association could not be determined. Please use the :inverse_name option to specify the inverse association name for this cache."
@@ -147,7 +147,8 @@ class NormalizedHasManyTest < IdentityCache::TestCase
147
147
 
148
148
  def test_saving_child_with_touch_true_on_parent_expires_parent
149
149
  IdentityCache.cache.expects(:delete).with(@record.primary_cache_index_key).once
150
- @not_cached.save
150
+ @not_cached.name = 'Changed'
151
+ @not_cached.save!
151
152
  end
152
153
 
153
154
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: identity_cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Camilo Lopez
@@ -13,30 +13,8 @@ authors:
13
13
  - Francis Bogsanyi
14
14
  autorequire:
15
15
  bindir: bin
16
- cert_chain:
17
- - |
18
- -----BEGIN CERTIFICATE-----
19
- MIIDcDCCAligAwIBAgIBATANBgkqhkiG9w0BAQUFADA/MQ8wDQYDVQQDDAZhZG1p
20
- bnMxFzAVBgoJkiaJk/IsZAEZFgdzaG9waWZ5MRMwEQYKCZImiZPyLGQBGRYDY29t
21
- MB4XDTE0MDUxNTIwMzM0OFoXDTE1MDUxNTIwMzM0OFowPzEPMA0GA1UEAwwGYWRt
22
- aW5zMRcwFQYKCZImiZPyLGQBGRYHc2hvcGlmeTETMBEGCgmSJomT8ixkARkWA2Nv
23
- bTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL0/81O3e1vh5smcwp2G
24
- MpLQ6q0kejQLa65bPYPxdzWA1SYOKyGfw+yR9LdFzsuKpwWzKq6zX35lj1IckWS4
25
- bNBEQzxmufUxU0XPM02haFB8fOfDJzdXsWte9Ge4IFwahwn68gpMqN+BvxL+KMYz
26
- Iut9YmN44d4LZdsENEIO5vmybuG2vYDz7R56qB0PA+Q2P2CdhymsBad2DQs69FBo
27
- uico9V6VMYYctL9lCYdzu9IXrOYNTt88suKIVzzAlHOKeN0Ng5qdztFoTR8sfxDr
28
- Ydg3KHl5n47wlpgd8R0f/4b5gGxW+v9pyJCgQnLlRu7DedVSvv7+GMtj3g9r3nhJ
29
- KqECAwEAAaN3MHUwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFI/o
30
- maf34HXbUOQsdoLHacEKQgunMB0GA1UdEQQWMBSBEmFkbWluc0BzaG9waWZ5LmNv
31
- bTAdBgNVHRIEFjAUgRJhZG1pbnNAc2hvcGlmeS5jb20wDQYJKoZIhvcNAQEFBQAD
32
- ggEBADkK9aj5T0HPExsov4EoMWFnO+G7RQ28C30VAfKxnL2UxG6i4XMHVs6Xi94h
33
- qXFw1ec9Y2eDUqaolT3bviOk9BB197+A8Vz/k7MC6ci2NE+yDDB7HAC8zU6LAx8Y
34
- Iqvw7B/PSZ/pz4bUVFlTATif4mi1vO3lidRkdHRtM7UePSn2rUpOi0gtXBP3bLu5
35
- YjHJN7wx5cugMEyroKITG5gL0Nxtu21qtOlHX4Hc4KdE2JqzCPOsS4zsZGhgwhPs
36
- fl3hbtVFTqbOlwL9vy1fudXcolIE/ZTcxQ+er07ZFZdKCXayR9PPs64heamfn0fp
37
- TConQSX2BnZdhIEYW+cKzEC/bLc=
38
- -----END CERTIFICATE-----
39
- date: 2015-01-06 00:00:00.000000000 Z
16
+ cert_chain: []
17
+ date: 2015-05-13 00:00:00.000000000 Z
40
18
  dependencies:
41
19
  - !ruby/object:Gem::Dependency
42
20
  name: ar_transaction_changes
@@ -289,7 +267,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
289
267
  version: '0'
290
268
  requirements: []
291
269
  rubyforge_project:
292
- rubygems_version: 2.2.2
270
+ rubygems_version: 2.4.5
293
271
  signing_key:
294
272
  specification_version: 4
295
273
  summary: IdentityCache lets you specify how you want to cache your model objects,
checksums.yaml.gz.sig DELETED
@@ -1,4 +0,0 @@
1
- �Es\�ϖD�&v��g Sv�1LRO�T��������lR�5_\&'no��E`
2
- ��;DLpd�վè��+gT^�
3
- fs���%8e�3����E���-��
4
- 4[
data.tar.gz.sig DELETED
@@ -1,2 +0,0 @@
1
- \�� ��.C��gFJ��`vG971"א�����\ԑ���'�+/MWy�Cro�����C��BIH\�S�8�栔`<�1pd��l�W=G����"^`Id�����Q����{��a���W��Q���P�:��f����)f�y�ܺ��F����Ȏ����o�>�>=��XQ̱n�h{K�Z�8��Js^�Q�w�؆� 9��’8X$�/I� �l$�J��>�Ȫ U-��WJ9�v�m@�/tf��)Uo�.
2
- YY��
metadata.gz.sig DELETED
Binary file