Class: TableSync::Publishing::Data::Raw

Inherits:
Object
  • Object
show all
Defined in:
lib/table_sync/publishing/data/raw.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model_name:, attributes_for_sync:, event:) ⇒ Raw



7
8
9
10
11
# File 'lib/table_sync/publishing/data/raw.rb', line 7

def initialize(model_name:, attributes_for_sync:, event:)
  @model_name = model_name
  @attributes_for_sync = attributes_for_sync
  @event = TableSync::Event.new(event)
end

Instance Attribute Details

#attributes_for_syncObject (readonly)

Returns the value of attribute attributes_for_sync.



5
6
7
# File 'lib/table_sync/publishing/data/raw.rb', line 5

def attributes_for_sync
  @attributes_for_sync
end

#eventObject (readonly)

Returns the value of attribute event.



5
6
7
# File 'lib/table_sync/publishing/data/raw.rb', line 5

def event
  @event
end

#model_nameObject (readonly)

Returns the value of attribute model_name.



5
6
7
# File 'lib/table_sync/publishing/data/raw.rb', line 5

def model_name
  @model_name
end

Instance Method Details

#constructObject



13
14
15
16
17
18
19
20
21
# File 'lib/table_sync/publishing/data/raw.rb', line 13

def construct
  {
    model: model_name,
    attributes: wrapped_attributes_for_sync,
    version: version,
    event: event.resolve,
    metadata: event.,
  }
end

#versionObject



27
28
29
# File 'lib/table_sync/publishing/data/raw.rb', line 27

def version
  Time.current.to_f
end

#wrapped_attributes_for_syncObject



23
24
25
# File 'lib/table_sync/publishing/data/raw.rb', line 23

def wrapped_attributes_for_sync
  attributes_for_sync.is_a?(Array) ? attributes_for_sync : [attributes_for_sync]
end