mongoid-encrypted-fields 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MmI2YWVkOGM2ZjlmOTY1NmQxMDJhNzNjMzhkNTdkZmVjNGY2NTA2Yw==
4
+ ZGQyOGY5NmI1MzRjMmEzMTA3MTgyOTc2YWQ4Nzk2OTJlNzdjNmM3MQ==
5
5
  data.tar.gz: !binary |-
6
- NmFkYzIzNjBlNWNjYTNmYTQ5NzI0ZjEwMzliODhkYjQ4NDUzYWI1ZQ==
7
- !binary "U0hBNTEy":
6
+ NGMxNDlkOWNhMDkzMzViMDljMjUzZmZiNWJhYjc4ZDdiNmQ1NTRjMA==
7
+ SHA512:
8
8
  metadata.gz: !binary |-
9
- MjI5MTUxMmY5NzEzMjRiYmZjZjZjM2Y1ZGVhOGI3MTUzYzhhYzlkNmJmOGJj
10
- N2EzYzk0ZDM0NzQ4N2NlYzZjZTZiNjJjZmY2NWM4OWNlMThlNDhlNDZkMzlh
11
- YWFmZDc5ODhlOTM4ZWQ4OTM2ZDcyZWQzNDlkM2JiOTExZDdkOGQ=
9
+ ODkwNTU5NjAzYmIzNDc1NTM4MjYxMDcwZTYzMGQ4MDNlMmY3MGVlYzM0Njll
10
+ MmViNjdkNTkxMThkYmVkOGZhNjk4Mjg2YjFmZmRiYjQ4NzYwOWJhNzk5ZWZk
11
+ YjY0ZDI0MTE2NmM2Mjc1M2MwMWNiY2M3OGNiODgxNmI0NDIyOTI=
12
12
  data.tar.gz: !binary |-
13
- NTVlOWZkNmNlZWI5OGU0NWE1NmNhMjZhNjFmODRiY2ZmMDBlMjYyZTFlZmI0
14
- ZmRhNDY0NjY5YTc2YjZmNDVjNTI4OWIxYmU3MGRmMDQ3OTZjODMyOGNhNmZk
15
- MDY4OTllMjJkOTJhMjA2YmYzMjMwZTUzZDlkNDNhYzI3NzU3OTI=
13
+ Y2NiNDY4NDU4Y2ZiZjk2ZGM0ZGJkYzYxYjk0YjVhZWUwNGY4Mjc3ODI0ZGYz
14
+ OTk2ZTkyZDA3MjljNTUyOWY3NTEzODljNmEzZDljZjMyYmM2OWM5Mjc5YTdj
15
+ ZmJhOGE4ZjBmYjgzOTgxOTQ4Y2FjOWJlYzYwN2I1MGEzZDNjMjA=
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Revision history
2
2
 
3
+ ## 1.3.1
4
+ * \#14 Updates due to changes in Mongoid 4 and ActiveModel 4
5
+
3
6
  ## 1.3.0 - Breaking change - PLEASE READ
4
7
  * \#11 Support for Mongoid 4
5
8
  * \#12 EncryptedHash will now stringify the keys before storing to be consistent with Mongoid's behavior
data/README.md CHANGED
@@ -52,7 +52,7 @@ Queries encrypt data before searching the database, so equality matches work aut
52
52
  ```Ruby
53
53
  Person.where(ssn: '123456789').count() # ssn is encrypted before querying the database
54
54
  ```
55
- * The Mongoid uniqueness validator is patched to detect of encrypted fields:
55
+ * The Mongoid uniqueness validator is patched to detect encrypted fields:
56
56
  ```Ruby
57
57
  class Person
58
58
  ...
@@ -27,7 +27,7 @@ case ::Mongoid::EncryptedFields.mongoid_major_version
27
27
  when 3
28
28
  require 'mongoid-encrypted-fields/mongoid3/validations/uniqueness'
29
29
  when 4
30
- require 'mongoid-encrypted-fields/mongoid4/validations/uniqueness'
30
+ require 'mongoid-encrypted-fields/mongoid4/validatable/uniqueness'
31
31
  else
32
32
  raise "Unsupported version of Mongoid: #{::Mongoid::VERSION::MAJOR}"
33
33
  end
@@ -7,19 +7,29 @@ module Mongoid
7
7
  # for encrypted fields; they must always be case-sensitive.
8
8
  # Patch is confirmed to work on Mongoid >= 4.0.0
9
9
  class UniquenessValidator
10
+ attr_reader :klass
10
11
 
11
- def setup_with_validation(klass)
12
- setup_without_validation(klass)
12
+ # Older versions of Mongoid's UniquenessValidator have a klass variable to reference the validating document
13
+ # This was later replaced in ActiveModel with options[:class]
14
+ def initialize(options={})
15
+ super
16
+ @klass = options[:class]
17
+ end
18
+
19
+ def setup(klass)
20
+ @klass = klass
21
+ check_validity!
22
+ end
23
+
24
+ def check_validity!
13
25
  return if case_sensitive?
26
+ return unless klass
14
27
  attributes.each do |attribute|
15
- field_type = @klass.fields[@klass.database_field_name(attribute)].options[:type]
28
+ field_type = klass.fields[klass.database_field_name(attribute)].options[:type]
16
29
  raise ArgumentError, "Encrypted field :#{attribute} cannot support case insensitive uniqueness" if field_type.method_defined?(:encrypted)
17
30
  end
18
31
  end
19
32
 
20
- alias_method :setup_without_validation, :setup
21
- alias_method :setup, :setup_with_validation
22
-
23
33
  end
24
34
  end
25
35
  end
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module EncryptedFields
3
- VERSION = '1.3.0'
3
+ VERSION = '1.3.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-encrypted-fields
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Koan Health
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-10 00:00:00.000000000 Z
11
+ date: 2014-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid
@@ -115,6 +115,11 @@ executables: []
115
115
  extensions: []
116
116
  extra_rdoc_files: []
117
117
  files:
118
+ - CHANGELOG.md
119
+ - LICENSE.txt
120
+ - README.md
121
+ - Rakefile
122
+ - lib/mongoid-encrypted-fields.rb
118
123
  - lib/mongoid-encrypted-fields/fields/encrypted_date.rb
119
124
  - lib/mongoid-encrypted-fields/fields/encrypted_date_time.rb
120
125
  - lib/mongoid-encrypted-fields/fields/encrypted_field.rb
@@ -123,13 +128,8 @@ files:
123
128
  - lib/mongoid-encrypted-fields/fields/encrypted_time.rb
124
129
  - lib/mongoid-encrypted-fields/logging.rb
125
130
  - lib/mongoid-encrypted-fields/mongoid3/validations/uniqueness.rb
126
- - lib/mongoid-encrypted-fields/mongoid4/validations/uniqueness.rb
131
+ - lib/mongoid-encrypted-fields/mongoid4/validatable/uniqueness.rb
127
132
  - lib/mongoid-encrypted-fields/version.rb
128
- - lib/mongoid-encrypted-fields.rb
129
- - CHANGELOG.md
130
- - LICENSE.txt
131
- - README.md
132
- - Rakefile
133
133
  - spec/config/mongoid.yml
134
134
  - spec/mongoid-encrypted-fields/fields/encrypted_date_spec.rb
135
135
  - spec/mongoid-encrypted-fields/fields/encrypted_datetime_spec.rb
@@ -139,7 +139,7 @@ files:
139
139
  - spec/mongoid-encrypted-fields/fields/encrypted_time_spec.rb
140
140
  - spec/mongoid-encrypted-fields/fields/model_spec.rb
141
141
  - spec/mongoid-encrypted-fields/mongoid3/validations/uniqueness_spec.rb
142
- - spec/mongoid-encrypted-fields/mongoid4/validations/uniqueness_spec.rb
142
+ - spec/mongoid-encrypted-fields/mongoid4/validatable/uniqueness_spec.rb
143
143
  - spec/spec_helper.rb
144
144
  - spec/support/models/person.rb
145
145
  homepage: https://github.com/KoanHealth/mongoid-encrypted-fields
@@ -162,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
162
  version: 1.3.6
163
163
  requirements: []
164
164
  rubyforge_project:
165
- rubygems_version: 2.0.6
165
+ rubygems_version: 2.2.2
166
166
  signing_key:
167
167
  specification_version: 4
168
168
  summary: Custom types for storing encrypted data
@@ -176,6 +176,6 @@ test_files:
176
176
  - spec/mongoid-encrypted-fields/fields/encrypted_time_spec.rb
177
177
  - spec/mongoid-encrypted-fields/fields/model_spec.rb
178
178
  - spec/mongoid-encrypted-fields/mongoid3/validations/uniqueness_spec.rb
179
- - spec/mongoid-encrypted-fields/mongoid4/validations/uniqueness_spec.rb
179
+ - spec/mongoid-encrypted-fields/mongoid4/validatable/uniqueness_spec.rb
180
180
  - spec/spec_helper.rb
181
181
  - spec/support/models/person.rb