Class: Warren::Message::Full

Inherits:
Object
  • Object
show all
Defined in:
lib/warren/message/full.rb

Overview

Generates a payload of an active_record object

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(record) ⇒ Full

Returns a new instance of Full.



9
10
11
# File 'lib/warren/message/full.rb', line 9

def initialize(record)
  @record = record
end

Instance Attribute Details

#recordObject (readonly)

Returns the value of attribute record.



7
8
9
# File 'lib/warren/message/full.rb', line 7

def record
  @record
end

Instance Method Details

#headers{}

For compatibility. Returns an empty hash.

Returns:

  • ({})

    Empty hash



41
42
43
# File 'lib/warren/message/full.rb', line 41

def headers
  {}
end

#payloadString

The payload of the message.

Returns:

  • (String)

    The message payload

See Also:



33
34
35
# File 'lib/warren/message/full.rb', line 33

def payload
  MultiJson.dump(record)
end

#routing_keyString

The routing key that will be used for the message, not including the routing_key_prefix configured in warren.yml. If #record responds to ‘routing_key` will use that instead

Returns:

  • (String)

    The routing key.



20
21
22
23
24
25
26
# File 'lib/warren/message/full.rb', line 20

def routing_key
  if record.respond_to?(:routing_key)
    record.routing_key
  else
    "saved.#{record.class.name.underscore}.#{record.id}"
  end
end