Class: TableSync::Publishing::Message::Raw

Inherits:
Object
  • Object
show all
Includes:
Tainbox
Defined in:
lib/table_sync/publishing/message/raw.rb

Instance Method Summary collapse

Instance Method Details

#dataObject



41
42
43
44
45
# File 'lib/table_sync/publishing/message/raw.rb', line 41

def data
  TableSync::Publishing::Data::Raw.new(
    model_name: model_name, attributes_for_sync: original_attributes, event: event,
  ).construct
end

#message_paramsObject

MESSAGE PARAMS



37
38
39
# File 'lib/table_sync/publishing/message/raw.rb', line 37

def message_params
  params.merge(data: data)
end

#notify!Object

NOTIFY



25
26
27
28
29
30
31
32
33
# File 'lib/table_sync/publishing/message/raw.rb', line 25

def notify!
  TableSync::Instrument.notify(
    table: table_name,
    schema: schema_name,
    event: event,
    count: original_attributes.count,
    direction: :publish,
  )
end

#paramsObject



47
48
49
50
51
# File 'lib/table_sync/publishing/message/raw.rb', line 47

def params
  TableSync::Publishing::Params::Raw.new(
    attributes.slice(:model_name, :headers, :routing_key).compact,
  ).construct
end

#publishObject



17
18
19
20
21
# File 'lib/table_sync/publishing/message/raw.rb', line 17

def publish
  Rabbit.publish(message_params)

  notify!
end