Class: TableSync::Publishing::Single

Inherits:
Object
  • Object
show all
Includes:
Memery
Defined in:
lib/table_sync/publishing/single.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Single

Returns a new instance of Single.



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

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

  self.object_class         = attrs[:object_class]
  self.original_attributes  = attrs[:original_attributes]
  self.debounce_time        = attrs[:debounce_time]
  self.custom_version       = attrs[:custom_version]
  self.event                = attrs.fetch(:event, :update)
end

Instance Attribute Details

#custom_versionObject

Returns the value of attribute custom_version.



6
7
8
# File 'lib/table_sync/publishing/single.rb', line 6

def custom_version
  @custom_version
end

#debounce_timeObject

Returns the value of attribute debounce_time.



6
7
8
# File 'lib/table_sync/publishing/single.rb', line 6

def debounce_time
  @debounce_time
end

#eventObject

Returns the value of attribute event.



6
7
8
# File 'lib/table_sync/publishing/single.rb', line 6

def event
  @event
end

#object_classObject

Returns the value of attribute object_class.



6
7
8
# File 'lib/table_sync/publishing/single.rb', line 6

def object_class
  @object_class
end

#original_attributesObject

Returns the value of attribute original_attributes.



6
7
8
# File 'lib/table_sync/publishing/single.rb', line 6

def original_attributes
  @original_attributes
end

Instance Method Details

#publish_laterObject

expect job to have perform_at method debounce destroyed event because otherwise update event could be sent after destroy



25
26
27
28
29
30
31
# File 'lib/table_sync/publishing/single.rb', line 25

def publish_later
  return if debounce.skip?

  job.perform_at(job_attributes)

  debounce.cache_next_sync_time
end

#publish_nowObject



33
34
35
# File 'lib/table_sync/publishing/single.rb', line 33

def publish_now
  message.publish unless message.empty?
end