Class: TableSync::Publishing::Data::Raw
- Inherits:
-
Object
- Object
- TableSync::Publishing::Data::Raw
- Defined in:
- lib/table_sync/publishing/data/raw.rb
Instance Attribute Summary collapse
-
#attributes_for_sync ⇒ Object
readonly
Returns the value of attribute attributes_for_sync.
-
#custom_version ⇒ Object
readonly
Returns the value of attribute custom_version.
-
#event ⇒ Object
readonly
Returns the value of attribute event.
-
#model_name ⇒ Object
readonly
Returns the value of attribute model_name.
Instance Method Summary collapse
- #construct ⇒ Object
-
#initialize(model_name:, attributes_for_sync:, event:, custom_version:) ⇒ Raw
constructor
A new instance of Raw.
- #version ⇒ Object
- #wrapped_attributes_for_sync ⇒ Object
Constructor Details
#initialize(model_name:, attributes_for_sync:, event:, custom_version:) ⇒ Raw
Returns a new instance of Raw.
7 8 9 10 11 12 |
# File 'lib/table_sync/publishing/data/raw.rb', line 7 def initialize(model_name:, attributes_for_sync:, event:, custom_version:) @model_name = model_name @attributes_for_sync = attributes_for_sync @event = TableSync::Event.new(event) @custom_version = custom_version end |
Instance Attribute Details
#attributes_for_sync ⇒ Object (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 |
#custom_version ⇒ Object (readonly)
Returns the value of attribute custom_version.
5 6 7 |
# File 'lib/table_sync/publishing/data/raw.rb', line 5 def custom_version @custom_version end |
#event ⇒ Object (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_name ⇒ Object (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
#construct ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/table_sync/publishing/data/raw.rb', line 14 def construct { model: model_name, attributes: wrapped_attributes_for_sync, version: custom_version || version, event: event.resolve, metadata: event., } end |
#version ⇒ Object
28 29 30 |
# File 'lib/table_sync/publishing/data/raw.rb', line 28 def version Time.current.to_f end |
#wrapped_attributes_for_sync ⇒ Object
24 25 26 |
# File 'lib/table_sync/publishing/data/raw.rb', line 24 def wrapped_attributes_for_sync attributes_for_sync.is_a?(Array) ? attributes_for_sync : [attributes_for_sync] end |