blind_index 0.2.0 → 0.2.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 +5 -0
- data/README.md +9 -0
- data/lib/blind_index/extensions.rb +2 -2
- data/lib/blind_index/model.rb +5 -1
- data/lib/blind_index/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c05a4761d6d0ea7b3b509af0f470323b2dad0acf50b8e1278bf0c65ae77bce3
|
4
|
+
data.tar.gz: bc9acee38ec03827dde2faacd9f0fc83c6a1900888dbe472d3d1e3b5971c532d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53f9fb4eea7741c64a353e14b229a7c176bcd80d156e691a727477508aa995785611da57adf3c01d553415b39061798831a3ab49988cf4ef43a7343ead42f446
|
7
|
+
data.tar.gz: 4671cdb7b7f3c33476bf629ab406e35496db7a5075c0da0b5f5190ae50c68447bdff68299b151072d3118569715dd84d9b7ff0fd4ad1056c84bb7af6b58b45eb
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -122,6 +122,15 @@ class User < ApplicationRecord
|
|
122
122
|
end
|
123
123
|
```
|
124
124
|
|
125
|
+
## Fixtures
|
126
|
+
|
127
|
+
You can use blind indexes in fixtures with:
|
128
|
+
|
129
|
+
```yml
|
130
|
+
test_user:
|
131
|
+
encrypted_email_bidx: <%= User.compute_email_bidx("test@example.org").inspect %>
|
132
|
+
```
|
133
|
+
|
125
134
|
## History
|
126
135
|
|
127
136
|
View the [changelog](https://github.com/ankane/blind_index/blob/master/CHANGELOG.md)
|
@@ -6,7 +6,7 @@ module BlindIndex
|
|
6
6
|
new_hash = super
|
7
7
|
if has_blind_indexes?
|
8
8
|
hash.each do |key, _|
|
9
|
-
if (bi = klass.blind_indexes[key])
|
9
|
+
if (bi = klass.blind_indexes[key]) && !new_hash[key].is_a?(ActiveRecord::StatementCache::Substitute)
|
10
10
|
new_hash[bi[:bidx_attribute]] = BlindIndex.generate_bidx(new_hash.delete(key), bi)
|
11
11
|
end
|
12
12
|
end
|
@@ -29,7 +29,7 @@ module BlindIndex
|
|
29
29
|
new_hash = super
|
30
30
|
if has_blind_indexes?(klass)
|
31
31
|
hash.each do |key, _|
|
32
|
-
if (bi = klass.blind_indexes[key])
|
32
|
+
if (bi = klass.blind_indexes[key]) && !new_hash[key].is_a?(ActiveRecord::StatementCache::Substitute)
|
33
33
|
new_hash[bi[:bidx_attribute]] = BlindIndex.generate_bidx(new_hash.delete(key), bi)
|
34
34
|
end
|
35
35
|
end
|
data/lib/blind_index/model.rb
CHANGED
@@ -26,8 +26,12 @@ module BlindIndex
|
|
26
26
|
bidx_attribute: bidx_attribute
|
27
27
|
}
|
28
28
|
|
29
|
+
define_singleton_method method_name do |value|
|
30
|
+
BlindIndex.generate_bidx(value, blind_indexes[name])
|
31
|
+
end
|
32
|
+
|
29
33
|
define_method method_name do
|
30
|
-
self.send("#{bidx_attribute}=",
|
34
|
+
self.send("#{bidx_attribute}=", self.class.send(method_name, send(attribute)))
|
31
35
|
end
|
32
36
|
|
33
37
|
if callback
|
data/lib/blind_index/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blind_index
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|