Class: ActiveRecord::ConnectionAdapters::CipherStashColumnMapper

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/connection_adapters/cipherstash_column_mapper.rb

Overview

A module for mapping CipherStash internal columns to columns that ActiveRecord can work with.

Constant Summary collapse

ENCRYPTED_INDEX_COLUMN_REGEX =
/^__.+_(match|ore|unique)$/
ENCRYPTED_SOURCE_COLUMN_REGEX =
/^__(.+)_encrypted$/

Class Method Summary collapse

Class Method Details

.map_column_definitions(column_definitions) ⇒ Object

Maps the given column definitions by filtering out CipherStash internal columns. This method also adds in plaintext columns if necessary (for example, when using the driver in “encrypted” mode after the original plaintext columns have been dropped).



16
17
18
19
20
21
22
23
# File 'lib/active_record/connection_adapters/cipherstash_column_mapper.rb', line 16

def map_column_definitions(column_definitions)
  all_column_names = column_definitions.map(&:first).to_set

  column_definitions
    .reject { |column_definition| encrypted_index_column?(column_definition) }
    .map { |column_definition| maybe_rename_source_column(column_definition, all_column_names) }
    .reject { |column_definition| encrypted_source_column?(column_definition) }
end