Module: ActiveRecord::Encryption::ExtendedDeterministicQueries::RelationQueries

Defined in:
lib/active_record/encryption/extended_deterministic_queries.rb

Instance Method Summary collapse

Instance Method Details

#exists?(*args) ⇒ Boolean

Returns:

  • (Boolean)


101
102
103
# File 'lib/active_record/encryption/extended_deterministic_queries.rb', line 101

def exists?(*args)
  super(*EncryptedQuery.process_arguments(self, args, true))
end

#scope_for_createObject



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/active_record/encryption/extended_deterministic_queries.rb', line 105

def scope_for_create
  return super unless klass.deterministic_encrypted_attributes&.any?

  scope_attributes = super
  wheres = where_values_hash

  klass.deterministic_encrypted_attributes.each do |attribute_name|
    attribute_name = attribute_name.to_s
    values = wheres[attribute_name]
    if values.is_a?(Array) && values[1..].all?(AdditionalValue)
      scope_attributes[attribute_name] = values.first
    end
  end

  scope_attributes
end

#where(*args) ⇒ Object



97
98
99
# File 'lib/active_record/encryption/extended_deterministic_queries.rb', line 97

def where(*args)
  super(*EncryptedQuery.process_arguments(self, args, true))
end