lib/lockbox/model.rb in lockbox-0.6.6 vs lib/lockbox/model.rb in lockbox-0.6.7

- old
+ new

@@ -312,9 +312,19 @@ define_method("#{name}?") do # uses public_send, so we don't need to preload attribute query_attribute(name) end + + user_provided_default = + if ActiveRecord::VERSION::STRING >= "5.2" + ActiveModel::Attribute::UserProvidedDefault + else + ActiveRecord::Attribute::UserProvidedDefault + end + if _default_attributes[name.to_s].is_a?(user_provided_default) + warn "[lockbox] WARNING: attributes with `:default` option are not supported. Use `after_initialize` instead." + 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