voltron-encrypt 0.1.9 → 0.1.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/voltron/encrypt/version.rb +1 -1
- data/lib/voltron/encryptable.rb +18 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d2a09a73b2b93a6e3eacf786b71a296bc30fa24
|
4
|
+
data.tar.gz: 3e0d200ee6f8fa180e21f3b2f914db2979555697
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac82895b787aa4d4d3392389f65b1a5906c3997ce2a481a2e6f4469d578e77fc841a45acaacb323c3950e421ae680fb06cd9a6696f3d4bec3bd1260d0c9ab717
|
7
|
+
data.tar.gz: 0bb0868de53f96c74ca98f8454d40ffb05325ecf61bee92e35f7b26fb79d2d9bb123e1bf4788cc179b4131021860c5756d56b500b8cef1e0cc4bdff28cf9a45a
|
data/lib/voltron/encryptable.rb
CHANGED
@@ -85,6 +85,24 @@ module Voltron
|
|
85
85
|
super(new_attributes)
|
86
86
|
end
|
87
87
|
|
88
|
+
def update_attributes(attributes)
|
89
|
+
attributes.symbolize_keys!
|
90
|
+
belongs = self.class.reflect_on_all_associations(:belongs_to).map { |b| { column: "#{b.name}_id", class_name: (b.options[:class_name] || b.name).to_s.classify } }
|
91
|
+
|
92
|
+
belongs.each do |belong|
|
93
|
+
begin
|
94
|
+
klass = belong[:class_name].safe_constantize
|
95
|
+
value = attributes[belong[:column]]
|
96
|
+
next if !klass.has_encrypted_id? || value.blank?
|
97
|
+
record = klass.find(value)
|
98
|
+
attributes[belong[:column]] = record.id
|
99
|
+
rescue NameError, ActiveRecord::RecordNotFound
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
super(attributes)
|
104
|
+
end
|
105
|
+
|
88
106
|
def to_param
|
89
107
|
return super if encryptable.nil?
|
90
108
|
|