Class: TableSync::Publishing::Batch

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

Direct Known Subclasses

Params::Raw

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Batch

Returns a new instance of Batch.



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/table_sync/publishing/batch.rb', line 11

def initialize(attrs = {})
  attrs = attrs.with_indifferent_access

  self.object_class         = attrs[:object_class]
  self.original_attributes  = attrs[:original_attributes]
  self.custom_version       = attrs[:custom_version]
  self.routing_key          = attrs[:routing_key]
  self.headers              = attrs[:headers]
  self.event                = attrs.fetch(:event, :update).to_sym

  validate_required_attributes!
end

Instance Attribute Details

#custom_versionObject

Returns the value of attribute custom_version.



4
5
6
# File 'lib/table_sync/publishing/batch.rb', line 4

def custom_version
  @custom_version
end

#eventObject

Returns the value of attribute event.



4
5
6
# File 'lib/table_sync/publishing/batch.rb', line 4

def event
  @event
end

#headersObject

Returns the value of attribute headers.



4
5
6
# File 'lib/table_sync/publishing/batch.rb', line 4

def headers
  @headers
end

#object_classObject

Returns the value of attribute object_class.



4
5
6
# File 'lib/table_sync/publishing/batch.rb', line 4

def object_class
  @object_class
end

#original_attributesObject

Returns the value of attribute original_attributes.



4
5
6
# File 'lib/table_sync/publishing/batch.rb', line 4

def original_attributes
  @original_attributes
end

#routing_keyObject

Returns the value of attribute routing_key.



4
5
6
# File 'lib/table_sync/publishing/batch.rb', line 4

def routing_key
  @routing_key
end

Instance Method Details

#messageObject



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

def message
  TableSync::Publishing::Message::Batch.new(attributes)
end

#publish_laterObject Also known as: publish_async



24
25
26
# File 'lib/table_sync/publishing/batch.rb', line 24

def publish_later
  job.perform_later(job_attributes)
end

#publish_nowObject



28
29
30
# File 'lib/table_sync/publishing/batch.rb', line 28

def publish_now
  message.publish
end