Class: Warren::Message

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(record) ⇒ Message

Returns a new instance of Message


4
5
6
# File 'lib/warren/message.rb', line 4

def initialize(record)
  @record = record
end

Instance Attribute Details

#recordObject (readonly)

Returns the value of attribute record


2
3
4
# File 'lib/warren/message.rb', line 2

def record
  @record
end

Instance Method Details

#payloadObject


16
17
18
# File 'lib/warren/message.rb', line 16

def payload
  MultiJson.dump(record)
end

#routing_keyObject


8
9
10
11
12
13
14
# File 'lib/warren/message.rb', line 8

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