Class: LiveEvents::BaseEvent
- Inherits:
-
CanvasSync::Job
- Object
- ActiveJob::Base
- CanvasSync::Job
- LiveEvents::BaseEvent
- Defined in:
- lib/canvas_sync/generators/templates/services/live_events/base_event.rb
Direct Known Subclasses
AssignmentEvent, AssignmentGroupEvent, CourseEvent, CourseSectionEvent, EnrollmentEvent, GradeEvent, ModuleEvent, ModuleItemEvent, SubmissionEvent, SyllabusEvent, UserEvent
Instance Attribute Summary collapse
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#payload ⇒ Object
Returns the value of attribute payload.
-
#raw_payload ⇒ Object
Returns the value of attribute raw_payload.
Attributes inherited from CanvasSync::Job
Instance Method Summary collapse
-
#local_canvas_id(id) ⇒ Object
Live events will use a canvas global ID (cross shard) for any ID’s provided.
- #perform(event_payload) ⇒ Object
- #process ⇒ Object
Methods inherited from CanvasSync::Job
#create_job_log, #report_checker_wait_time, #update_or_create_model
Instance Attribute Details
#metadata ⇒ Object
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 |
#payload ⇒ Object
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_payload ⇒ Object
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 |
#process ⇒ Object
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 |