lockbox 0.4.5 → 0.4.6
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 +4 -0
- data/lib/lockbox/model.rb +43 -0
- data/lib/lockbox/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: 2fb82c6baf0c56ae7f051c8363f7cb52554ebab8180b891d4aa25caf7505cec3
|
4
|
+
data.tar.gz: 64b6bda4259cc3fddd7e5635333b0b7c4a6680c4ff2da31bba735603ea50b010
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1953d9159c2cb1f1ec55436d925738777ea0b78afedcb32864280f7772d1d9e12a48f65c69385fd6bcdab166668049b3889f1e17e3b316c696705bcb98650dd
|
7
|
+
data.tar.gz: a3559c399a385949526137eed03b73c38baae424bed3b597c89f287222e6e18fd2c5665b2cbba6b20dad71bf680f0840ee2753a68befd3af40fdb522e45e4088
|
data/CHANGELOG.md
CHANGED
data/lib/lockbox/model.rb
CHANGED
@@ -107,6 +107,49 @@ module Lockbox
|
|
107
107
|
end
|
108
108
|
end
|
109
109
|
end
|
110
|
+
|
111
|
+
def update_columns(attributes)
|
112
|
+
return super unless attributes.is_a?(Hash)
|
113
|
+
|
114
|
+
# transform keys like Active Record
|
115
|
+
attributes = attributes.transform_keys do |key|
|
116
|
+
n = key.to_s
|
117
|
+
self.class.attribute_aliases[n] || n
|
118
|
+
end
|
119
|
+
|
120
|
+
lockbox_attributes = self.class.lockbox_attributes.slice(*attributes.keys.map(&:to_sym))
|
121
|
+
return super unless lockbox_attributes.any?
|
122
|
+
|
123
|
+
attributes_to_set = {}
|
124
|
+
|
125
|
+
lockbox_attributes.each do |key, lockbox_attribute|
|
126
|
+
attribute = key.to_s
|
127
|
+
# check read only
|
128
|
+
verify_readonly_attribute(attribute)
|
129
|
+
|
130
|
+
message = attributes[attribute]
|
131
|
+
attributes.delete(attribute) unless lockbox_attribute[:migrating]
|
132
|
+
encrypted_attribute = lockbox_attribute[:encrypted_attribute]
|
133
|
+
ciphertext = self.class.send("generate_#{encrypted_attribute}", message, context: self)
|
134
|
+
attributes[encrypted_attribute] = ciphertext
|
135
|
+
attributes_to_set[attribute] = message
|
136
|
+
attributes_to_set[lockbox_attribute[:attribute]] = message if lockbox_attribute[:migrating]
|
137
|
+
end
|
138
|
+
|
139
|
+
result = super(attributes)
|
140
|
+
|
141
|
+
# same logic as Active Record
|
142
|
+
# (although this happens before saving)
|
143
|
+
attributes_to_set.each do |k, v|
|
144
|
+
if respond_to?(:write_attribute_without_type_cast, true)
|
145
|
+
write_attribute_without_type_cast(k, v)
|
146
|
+
else
|
147
|
+
raw_write_attribute(k, v)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
result
|
152
|
+
end
|
110
153
|
else
|
111
154
|
def reload
|
112
155
|
self.class.lockbox_attributes.each do |_, v|
|
data/lib/lockbox/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lockbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|