lib/voltron/encryptable.rb in voltron-encrypt-0.1.9.2 vs lib/voltron/encryptable.rb in voltron-encrypt-0.2.0
- old
+ new
@@ -9,15 +9,10 @@
extend ClassMethods
include InstanceMethods
has_one :encryptable, as: :resource, class_name: "Voltron::Id"
- before_create do
- self.build_encryptable id: find_id
- end
-
- default_scope { joins(:encryptable).includes(:encryptable) }
-
+ before_save -> (i) { i.build_encryptable(id: find_id) }, if: proc { |i| i.encryptable.blank? }
end
module ClassMethods
def has_encrypted_id?
true