This is a wrapper for a hash of encryption properties. It is used by Key
(public tags) and Message
(headers).
Since properties are serialized in messages, it is important for storage efficiency to keep their keys as short as possible. It defines accessors for common properties that will keep these keys very short while exposing a readable name.
message.headers.encrypted_data_key # instead of message.headers[:k]
Methods
- #
- A
- N
- T
- V
Constants
ALLOWED_VALUE_CLASSES | = | [String, ActiveRecord::Encryption::Message, Numeric, Integer, Float, BigDecimal, TrueClass, FalseClass, Symbol, NilClass] |
DEFAULT_PROPERTIES | = | { encrypted_data_key: "k", encrypted_data_key_id: "i", compressed: "c", iv: "iv", auth_tag: "at", encoding: "e" } |
For each entry it generates an accessor exposing the full name |
Class Public methods
new(initial_properties = {}) Link
Instance Public methods
[]=(key, value) Link
Set a value for a given key
It will raise an EncryptedContentIntegrity
if the value exists
add(other_properties) Link
to_h() Link
validate_value_type(value) Link
# File activerecord/lib/active_record/encryption/properties.rb, line 56 def validate_value_type(value) unless ALLOWED_VALUE_CLASSES.include?(value.class) || ALLOWED_VALUE_CLASSES.any? { |klass| value.is_a?(klass) } raise ActiveRecord::Encryption::Errors::ForbiddenClass, "Can't store a #{value.class}, only properties of type #{ALLOWED_VALUE_CLASSES.inspect} are allowed" end end