Method: Cosmos::ActivityModel#notify

Defined in:
lib/cosmos/models/activity_model.rb

#notify(kind:, extra: nil) ⇒ Object

Returns [] update the redis stream / timeline topic that something has changed.

Returns:

  • update the redis stream / timeline topic that something has changed



289
290
291
292
293
294
295
296
297
298
299
300
301
302
# File 'lib/cosmos/models/activity_model.rb', line 289

def notify(kind:, extra: nil)
  notification = {
    'data' => JSON.generate(as_json()),
    'kind' => kind,
    'type' => 'activity',
    'timeline' => @name
  }
  notification['extra'] = extra unless extra.nil?
  begin
    TimelineTopic.write_activity(notification, scope: @scope)
  rescue StandardError => e
    raise ActivityError.new "Failed to write to stream: #{notification}, #{e}"
  end
end