Class: LiveEvents::BaseEvent

Inherits:
CanvasSync::Job show all
Defined in:
lib/canvas_sync/generators/templates/services/live_events/base_event.rb

Instance Attribute Summary collapse

Attributes inherited from CanvasSync::Job

#job_log

Instance Method Summary collapse

Methods inherited from CanvasSync::Job

#create_job_log, #report_checker_wait_time, #update_or_create_model

Instance Attribute Details

#metadataObject

Returns the value of attribute metadata.



9
10
11
# File 'lib/canvas_sync/generators/templates/services/live_events/base_event.rb', line 9

def 
  @metadata
end

#payloadObject

Returns the value of attribute payload.



8
9
10
# File 'lib/canvas_sync/generators/templates/services/live_events/base_event.rb', line 8

def payload
  @payload
end

#raw_payloadObject

Returns the value of attribute raw_payload.



7
8
9
# File 'lib/canvas_sync/generators/templates/services/live_events/base_event.rb', line 7

def raw_payload
  @raw_payload
end

Instance Method Details

#local_canvas_id(id) ⇒ Object

Live events will use a canvas global ID (cross shard) for any ID’s provided. This method will return the local ID.



23
24
25
# File 'lib/canvas_sync/generators/templates/services/live_events/base_event.rb', line 23

def local_canvas_id(id)
  id.to_i % 10_000_000_000_000
end

#perform(event_payload) ⇒ Object



11
12
13
14
15
16
# File 'lib/canvas_sync/generators/templates/services/live_events/base_event.rb', line 11

def perform(event_payload)
  @raw_payload = event_payload
  @metadata = HashWithIndifferentAccess.new(event_payload["attributes"])
  @payload = HashWithIndifferentAccess.new(event_payload["body"])
  process_with_retry
end

#processObject



18
19
20
# File 'lib/canvas_sync/generators/templates/services/live_events/base_event.rb', line 18

def process
  raise "process must be implemented in your subclass"
end