identity_cache 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/lib/identity_cache/configuration_dsl.rb +2 -2
- data/lib/identity_cache/version.rb +1 -1
- data/test/index_cache_test.rb +12 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3aaaad2b3f7ef8cd9c4aaeb338756bfcccfcbd4c
|
4
|
+
data.tar.gz: 06ee79bbcc777f7903139d9eab772ddcd50ad1af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0678a544ee6f53d428517c5a44409a1f93a9e690002f6c8d3efe1ee731f50aed2eef3c68b7bba5b66f4500b0fd5bdef9fc09e990a1e9a5ece1d0fac8e496ada6
|
7
|
+
data.tar.gz: c1313137f940b3e7c22523b9bf331416f4824288d4e45617931042641e73aabef0bc1d659384faf6be904d503164f80748c783fb5c3d216c72b1af0a6d40b2ba
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
# IdentityCache changelog
|
2
2
|
|
3
|
-
#### 0.
|
3
|
+
#### 0.3.1
|
4
|
+
|
5
|
+
- Fix cache_index for non-id primary key
|
6
|
+
|
7
|
+
#### 0.3.0
|
8
|
+
|
4
9
|
- Add support for includes option on cache_index and fetch_by_id
|
5
10
|
- Use ActiveRecord instantiate
|
6
11
|
- Add association pre-fetching support for fetch_by_id
|
@@ -51,7 +51,7 @@ module IdentityCache
|
|
51
51
|
if unique
|
52
52
|
self.instance_eval(ruby = <<-CODE, __FILE__, __LINE__ + 1)
|
53
53
|
def fetch_by_#{field_list}(#{arg_list}, options={})
|
54
|
-
id =
|
54
|
+
id = fetch_id_by_#{field_list}(#{arg_list})
|
55
55
|
id && fetch_by_id(id, options)
|
56
56
|
end
|
57
57
|
|
@@ -63,7 +63,7 @@ module IdentityCache
|
|
63
63
|
else
|
64
64
|
self.instance_eval(ruby = <<-CODE, __FILE__, __LINE__ + 1)
|
65
65
|
def fetch_by_#{field_list}(#{arg_list}, options={})
|
66
|
-
ids =
|
66
|
+
ids = fetch_id_by_#{field_list}(#{arg_list})
|
67
67
|
ids.empty? ? ids : fetch_multi(ids, options)
|
68
68
|
end
|
69
69
|
CODE
|
data/test/index_cache_test.rb
CHANGED
@@ -141,6 +141,18 @@ class IndexCacheTest < IdentityCache::TestCase
|
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
144
|
+
def test_cache_index_with_non_id_primary_key
|
145
|
+
KeyedRecord.cache_index :value
|
146
|
+
fixture = KeyedRecord.create!(value: "a") { |r| r.hashed_key = 123 }
|
147
|
+
assert_equal [123], KeyedRecord.fetch_by_value('a').map(&:id)
|
148
|
+
end
|
149
|
+
|
150
|
+
def test_unique_cache_index_with_non_id_primary_key
|
151
|
+
KeyedRecord.cache_index :value, unique: true
|
152
|
+
fixture = KeyedRecord.create!(value: "a") { |r| r.hashed_key = 123 }
|
153
|
+
assert_equal 123, KeyedRecord.fetch_by_value('a').id
|
154
|
+
end
|
155
|
+
|
144
156
|
private
|
145
157
|
|
146
158
|
def cache_key(unique: false)
|
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.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Camilo Lopez
|
@@ -268,7 +268,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
268
268
|
version: '0'
|
269
269
|
requirements: []
|
270
270
|
rubyforge_project:
|
271
|
-
rubygems_version: 2.2.
|
271
|
+
rubygems_version: 2.2.3
|
272
272
|
signing_key:
|
273
273
|
specification_version: 4
|
274
274
|
summary: IdentityCache lets you specify how you want to cache your model objects,
|