lib/lockbox/model.rb in lockbox-0.4.9 vs lib/lockbox/model.rb in lockbox-0.5.0

- old
+ new

@@ -25,12 +25,11 @@ raise ArgumentError, "Unknown type: #{options[:type]}" unless custom_type || [nil, :string, :boolean, :date, :datetime, :time, :integer, :float, :binary, :json, :hash, :array].include?(options[:type]) activerecord = defined?(ActiveRecord::Base) && self < ActiveRecord::Base raise ArgumentError, "Type not supported yet with Mongoid" if options[:type] && !activerecord - # TODO raise ArgumentError in 0.5.0 - warn "[lockbox] WARNING: No attributes specified" if attributes.empty? + raise ArgumentError, "No attributes specified" if attributes.empty? raise ArgumentError, "Cannot use key_attribute with multiple attributes" if options[:key_attribute] && attributes.size > 1 original_options = options.dup @@ -351,11 +350,11 @@ # for fixtures define_singleton_method encrypt_method_name do |message, **opts| table = activerecord ? table_name : collection_name.to_s unless message.nil? - # TODO use attribute type class in 0.5.0 + # TODO use attribute type class in 0.6.0 case options[:type] when :boolean message = ActiveRecord::Type::Boolean.new.serialize(message) message = nil if message == "" # for Active Record < 5.2 message = message ? "t" : "f" unless message.nil? @@ -406,10 +405,10 @@ table = activerecord ? table_name : collection_name.to_s Lockbox::Utils.build_box(opts[:context], options, table, encrypted_attribute).decrypt(ciphertext) end unless message.nil? - # TODO use attribute type class in 0.5.0 + # TODO use attribute type class in 0.6.0 case options[:type] when :boolean message = message == "t" when :date message = ActiveRecord::Type::Date.new.deserialize(message)