Module: Sequel::Plugins::ColumnEncryption::DatasetMethods
- Defined in:
- lib/sequel/plugins/column_encryption.rb
Instance Method Summary collapse
-
#needing_reencryption ⇒ Object
Filter the dataset to exclude rows where all encrypted columns are already encrypted with the current key and format.
-
#with_encrypted_value(column, value) ⇒ Object
Filter the dataset to only match rows where the column contains an encrypted version of value.
Instance Method Details
#needing_reencryption ⇒ Object
Filter the dataset to exclude rows where all encrypted columns are already encrypted with the current key and format.
717 718 719 720 721 722 723 724 |
# File 'lib/sequel/plugins/column_encryption.rb', line 717 def needing_reencryption incorrect_column_prefixes = model.send(:column_encryption_metadata).map do |column, | prefix = .key_searcher.call (Sequel[column] < prefix) | (Sequel[column] > prefix + 'B') end where(Sequel.|(*incorrect_column_prefixes)) end |
#with_encrypted_value(column, value) ⇒ Object
Filter the dataset to only match rows where the column contains an encrypted version of value. Only works on searchable encrypted columns.
704 705 706 707 708 709 710 711 712 713 |
# File 'lib/sequel/plugins/column_encryption.rb', line 704 def with_encrypted_value(column, value) = model.send(:column_encryption_metadata)[column] unless && .data_searcher raise Error, "lookup for encrypted column #{column.inspect} is not supported" end prefixes = .data_searcher.call(value) where(Sequel.|(*prefixes.map{|v| Sequel.like(column, "#{escape_like(v)}%")})) end |