lib/symmetric_encryption/generator.rb in symmetric-encryption-4.0.0 vs lib/symmetric_encryption/generator.rb in symmetric-encryption-4.0.1

- old
+ new

@@ -6,22 +6,22 @@ options = options.dup random_iv = options.delete(:random_iv) || false compress = options.delete(:compress) || false type = options.delete(:type) || :string - raise(ArgumentError, "SymmetricEncryption Invalid options #{options.inspect} when encrypting '#{decrypted_name}'") if options.size > 0 + raise(ArgumentError, "SymmetricEncryption Invalid options #{options.inspect} when encrypting '#{decrypted_name}'") unless options.empty? raise(ArgumentError, "Invalid type: #{type.inspect}. Valid types: #{SymmetricEncryption::COERCION_TYPES.inspect}") unless SymmetricEncryption::COERCION_TYPES.include?(type) if model.const_defined?(:EncryptedAttributes, _search_ancestors = false) mod = model.const_get(:EncryptedAttributes) else mod = model.const_set(:EncryptedAttributes, Module.new) model.send(:include, mod) end # Generate getter and setter methods - mod.module_eval(<<-EOS, __FILE__, __LINE__ + 1) + mod.module_eval(<<~ACCESSORS, __FILE__, __LINE__ + 1) # Set the un-encrypted field # Also updates the encrypted field with the encrypted value # Freeze the decrypted field value so that it is not modified directly def #{decrypted_name}=(value) v = SymmetricEncryption::Coerce.coerce(value, :#{type}) @@ -43,9 +43,9 @@ # Map changes to encrypted value to unencrypted equivalent def #{decrypted_name}_changed? #{encrypted_name}_changed? end - EOS + ACCESSORS end end end