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.



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

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
  self.compress             = attrs.fetch(:compress, false)

  validate_required_attributes!
end

Instance Attribute Details

#compressObject

Returns the value of attribute compress.



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

def compress
  @compress
end

#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



34
35
36
# File 'lib/table_sync/publishing/batch.rb', line 34

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

#publish_laterObject Also known as: publish_async



26
27
28
# File 'lib/table_sync/publishing/batch.rb', line 26

def publish_later
  job.perform_later(job_attributes)
end

#publish_nowObject



30
31
32
# File 'lib/table_sync/publishing/batch.rb', line 30

def publish_now
  message.publish
end