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



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

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

#message_paramsObject

MESSAGE PARAMS



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

def message_params
  params.merge(data: data)
end

#model_namingObject



32
33
34
# File 'lib/table_sync/publishing/message/raw.rb', line 32

def model_naming
  TableSync.publishing_adapter.model_naming(object_class.constantize)
end

#notify!Object

NOTIFY



22
23
24
25
26
27
28
29
30
# File 'lib/table_sync/publishing/message/raw.rb', line 22

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

#paramsObject



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

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

#publishObject



14
15
16
17
18
# File 'lib/table_sync/publishing/message/raw.rb', line 14

def publish
  Rabbit.publish(message_params)

  notify!
end