instance method
with_encryption_context
Ruby on Rails 7.0.10
Since v7.0.10Signature
with_encryption_context(properties)
Configures a custom encryption context to use when running the provided block of code.
It supports overriding all the properties defined in Context.
Example:
ActiveRecord::Encryption.with_encryption_context(encryptor: ActiveRecord::Encryption::NullEncryptor.new) do ... end
Encryption contexts can be nested.
Parameters
-
propertiesreq
Source
# File activerecord/lib/active_record/encryption/contexts.rb, line 33
def with_encryption_context(properties)
self.custom_contexts ||= []
self.custom_contexts << default_context.dup
properties.each do |key, value|
self.current_custom_context.send("#{key}=", value)
end
yield
ensure
self.custom_contexts.pop
end
Defined in activerecord/lib/active_record/encryption/contexts.rb line 33
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::Encryption::Contexts