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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a2f034adc1842667c23445f308df57c7f799d802190d570985037955eedab8d
4
- data.tar.gz: 7461ef87a66f92771aa4101624e5a025f4a3548a16b8c32b997371629542ee7a
3
+ metadata.gz: 5c05a4761d6d0ea7b3b509af0f470323b2dad0acf50b8e1278bf0c65ae77bce3
4
+ data.tar.gz: bc9acee38ec03827dde2faacd9f0fc83c6a1900888dbe472d3d1e3b5971c532d
5
5
  SHA512:
6
- metadata.gz: 343a9b809e3109bbc66bbbc842840837383c22c1707cb2a143949989b55f5230db3b7c8563f78db03b1edf54a2606f94bc0a68ec4891acfe25d571fef6ac3a1c
7
- data.tar.gz: 37083bfe331da9a1c7861009907a43e35a71d16db4c0cd1101af1033d1d023c305c4d47aee0e4ec17952c3ebc12c3d2fbda6cc48d284a231acd777fcfffa6cda
6
+ metadata.gz: 53f9fb4eea7741c64a353e14b229a7c176bcd80d156e691a727477508aa995785611da57adf3c01d553415b39061798831a3ab49988cf4ef43a7343ead42f446
7
+ data.tar.gz: 4671cdb7b7f3c33476bf629ab406e35496db7a5075c0da0b5f5190ae50c68447bdff68299b151072d3118569715dd84d9b7ff0fd4ad1056c84bb7af6b58b45eb
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.2.1
2
+
3
+ - Added class method to compute blind index
4
+ - Fixed issue with cached statements
5
+
1
6
  ## 0.2.0
2
7
 
3
8
  - Added support for ActiveRecord 4.2
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
@@ -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}=", BlindIndex.generate_bidx(send(attribute), self.class.blind_indexes[name]))
34
+ self.send("#{bidx_attribute}=", self.class.send(method_name, send(attribute)))
31
35
  end
32
36
 
33
37
  if callback
@@ -1,3 +1,3 @@
1
1
  module BlindIndex
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
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.0
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 00:00:00.000000000 Z
11
+ date: 2018-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport