Class: MicroBunny::Payload

Inherits:
Object
  • Object
show all
Defined in:
lib/microbunny/payload.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event:, message:, record: nil) ⇒ Payload

Returns a new instance of Payload.



11
12
13
14
15
# File 'lib/microbunny/payload.rb', line 11

def initialize(event:, message:, record: nil)
  @event = event
  @message = message
  @record = record
end

Instance Attribute Details

#eventObject

Returns the value of attribute event.



5
6
7
# File 'lib/microbunny/payload.rb', line 5

def event
  @event
end

#messageObject

Returns the value of attribute message.



5
6
7
# File 'lib/microbunny/payload.rb', line 5

def message
  @message
end

#recordObject

Returns the value of attribute record.



5
6
7
# File 'lib/microbunny/payload.rb', line 5

def record
  @record
end

Class Method Details

.deserialize(json) ⇒ Object



7
8
9
# File 'lib/microbunny/payload.rb', line 7

def self.deserialize(json)
  new JSON.parse(json, symbolize_names: true)
end

Instance Method Details

#serializeObject



17
18
19
# File 'lib/microbunny/payload.rb', line 17

def serialize
  {event: event, message: message, record: record}.to_json
end