Class: ActiveRecord::Encryption::Message

Inherits:
Object
  • Object
show all
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

See Encryptor#encrypt

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload: nil, headers: {}) ⇒ Message

Returns a new instance of Message.



14
15
16
17
18
19
# 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

#headersObject

Returns the value of attribute headers



12
13
14
# File 'activerecord/lib/active_record/encryption/message.rb', line 12

def headers
  @headers
end

#payloadObject

Returns the value of attribute payload



12
13
14
# File 'activerecord/lib/active_record/encryption/message.rb', line 12

def payload
  @payload
end

Instance Method Details

#==(other_message) ⇒ Object



21
22
23
# File 'activerecord/lib/active_record/encryption/message.rb', line 21

def ==(other_message)
  payload == other_message.payload && headers == other_message.headers
end