Class: ActiveRecord::Encryption::Message
Relationships & Source Files | |
Inherits: | Object |
Defined in: | activerecord/lib/active_record/encryption/message.rb |
Overview
A message defines the structure of the data we store in encrypted attributes. It contains:
-
An encrypted payload
-
A list of unencrypted headers
Class Method Summary
- .new(payload: nil, headers: {}) ⇒ Message constructor
Instance Attribute Summary
Instance Method Summary
Constructor Details
.new(payload: nil, headers: {}) ⇒ Message
# File 'activerecord/lib/active_record/encryption/message.rb', line 14
def initialize(payload: nil, headers: {}) validate_payload_type(payload) @payload = payload @headers = Properties.new(headers) end
Instance Attribute Details
#headers (rw)
[ GitHub ]# File 'activerecord/lib/active_record/encryption/message.rb', line 12
attr_accessor :payload, :headers
#payload (rw)
[ GitHub ]# File 'activerecord/lib/active_record/encryption/message.rb', line 12
attr_accessor :payload, :headers
Instance Method Details
#==(other_message)
[ GitHub ]#validate_payload_type(payload) (private)
[ GitHub ]# File 'activerecord/lib/active_record/encryption/message.rb', line 26
def validate_payload_type(payload) unless payload.is_a?(String) || payload.nil? raise ActiveRecord::Encryption::Errors::ForbiddenClass, "Only string payloads allowed" end end