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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fa14c04136f82edd405a78d88855d4808fddb0a8
4
- data.tar.gz: 5ae3c4dfcd91f7ceed2316757f767374ae61bb8a
3
+ metadata.gz: 3d2a09a73b2b93a6e3eacf786b71a296bc30fa24
4
+ data.tar.gz: 3e0d200ee6f8fa180e21f3b2f914db2979555697
5
5
  SHA512:
6
- metadata.gz: 7d2a889b81da37ceccfb3f8d98f4c79e96ad6e8d7951bcbda321929f8bd70dd635ae08cb419486b1faced2998572b3f0a0bd4786160ba3394d1b6cbf581094b8
7
- data.tar.gz: 6b1be01b3d36cf41be85bd1b7589a6726abe1a6879f61f7ad94b49a9e45fea8d0bf44a37e097e36c0903594f223fdcc0d2ca48accc62e4a19739fdcc12f1ad7e
6
+ metadata.gz: ac82895b787aa4d4d3392389f65b1a5906c3997ce2a481a2e6f4469d578e77fc841a45acaacb323c3950e421ae680fb06cd9a6696f3d4bec3bd1260d0c9ab717
7
+ data.tar.gz: 0bb0868de53f96c74ca98f8454d40ffb05325ecf61bee92e35f7b26fb79d2d9bb123e1bf4788cc179b4131021860c5756d56b500b8cef1e0cc4bdff28cf9a45a
@@ -1,5 +1,5 @@
1
1
  module Voltron
2
2
  class Encrypt
3
- VERSION = "0.1.9".freeze
3
+ VERSION = "0.1.9.1".freeze
4
4
  end
5
5
  end
@@ -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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: voltron-encrypt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Hainer