Class: MagicPipe::Envelope

Inherits:
Object
  • Object
show all
Defined in:
lib/magic_pipe/envelope.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body:, topic:, producer:, time:, mime:) ⇒ Envelope

Returns a new instance of Envelope.



3
4
5
6
7
8
9
# File 'lib/magic_pipe/envelope.rb', line 3

def initialize(body:, topic:, producer:, time:, mime:)
  @body = body
  @topic = topic
  @producer = producer
  @time = time.to_i
  @mime = mime
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



11
12
13
# File 'lib/magic_pipe/envelope.rb', line 11

def body
  @body
end

Instance Method Details

#==(other) ⇒ Object



25
26
27
# File 'lib/magic_pipe/envelope.rb', line 25

def ==(other)
  as_json == other.as_json
end

#as_jsonObject



14
15
16
17
18
19
20
21
22
# File 'lib/magic_pipe/envelope.rb', line 14

def as_json(*)
  {
    body: @body.as_json,
    topic: @topic,
    producer: @producer,
    time: @time,
    mime: @mime,
  }
end