Sha256: 758438e33b6423cb712ce993ee36a3cc299302628208ecf3fea9d0408476d79c

Contents?: true

Size: 912 Bytes

Versions: 41

Compression:

Stored size: 912 Bytes

Contents

# frozen_string_literal: true

module ActiveRecord
  module Encryption
    module ExtendedDeterministicUniquenessValidator
      def self.install_support
        ActiveRecord::Validations::UniquenessValidator.prepend(EncryptedUniquenessValidator)
      end

      module EncryptedUniquenessValidator
        def validate_each(record, attribute, value)
          super(record, attribute, value)

          klass = record.class
          klass.deterministic_encrypted_attributes&.each do |attribute_name|
            encrypted_type = klass.type_for_attribute(attribute_name)
            [ encrypted_type, *encrypted_type.previous_types ].each do |type|
              encrypted_value = type.serialize(value)
              ActiveRecord::Encryption.without_encryption do
                super(record, attribute, encrypted_value)
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

41 entries across 39 versions & 6 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/activerecord-7.0.8.7/lib/active_record/encryption/extended_deterministic_uniqueness_validator.rb
activerecord-7.0.8.7 lib/active_record/encryption/extended_deterministic_uniqueness_validator.rb
activerecord-7.0.8.6 lib/active_record/encryption/extended_deterministic_uniqueness_validator.rb
activerecord-7.0.8.5 lib/active_record/encryption/extended_deterministic_uniqueness_validator.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8.4/lib/active_record/encryption/extended_deterministic_uniqueness_validator.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/activerecord-7.0.5.1/lib/active_record/encryption/extended_deterministic_uniqueness_validator.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/activerecord-7.0.5.1/lib/active_record/encryption/extended_deterministic_uniqueness_validator.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/activerecord-7.0.5.1/lib/active_record/encryption/extended_deterministic_uniqueness_validator.rb
activerecord-7.0.8.4 lib/active_record/encryption/extended_deterministic_uniqueness_validator.rb
activerecord-7.0.8.1 lib/active_record/encryption/extended_deterministic_uniqueness_validator.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/activerecord-7.0.3.1/lib/active_record/encryption/extended_deterministic_uniqueness_validator.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/activerecord-7.0.2.3/lib/active_record/encryption/extended_deterministic_uniqueness_validator.rb
activerecord-7.0.8 lib/active_record/encryption/extended_deterministic_uniqueness_validator.rb
activerecord-7.0.7.2 lib/active_record/encryption/extended_deterministic_uniqueness_validator.rb
activerecord-7.0.7.1 lib/active_record/encryption/extended_deterministic_uniqueness_validator.rb
activerecord-7.0.7 lib/active_record/encryption/extended_deterministic_uniqueness_validator.rb
activerecord-7.0.6 lib/active_record/encryption/extended_deterministic_uniqueness_validator.rb
activerecord-7.0.5.1 lib/active_record/encryption/extended_deterministic_uniqueness_validator.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/activerecord-7.0.3.1/lib/active_record/encryption/extended_deterministic_uniqueness_validator.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/activerecord-7.0.2.3/lib/active_record/encryption/extended_deterministic_uniqueness_validator.rb