lib/lockbox/model.rb in lockbox-0.6.5 vs lib/lockbox/model.rb in lockbox-0.6.6
- old
+ new
@@ -307,10 +307,15 @@
define_method("#{name}_in_database") do
send(name) # writes attribute when not already set
super()
end
end
+
+ define_method("#{name}?") do
+ # uses public_send, so we don't need to preload attribute
+ query_attribute(name)
+ end
else
# keep this module dead simple
# Mongoid uses changed_attributes to calculate keys to update
# so we shouldn't mess with it
m = Module.new do
@@ -346,13 +351,13 @@
define_method "reset_#{name}_to_default!" do
instance_variable_set("@#{name}", nil)
send("reset_#{encrypted_attribute}_to_default!")
send(name)
end
- end
- define_method("#{name}?") do
- send("#{encrypted_attribute}?")
+ define_method("#{name}?") do
+ send("#{encrypted_attribute}?")
+ end
end
define_method("#{name}=") do |message|
# decrypt first for dirty tracking
# don't raise error if can't decrypt previous