Module: Timeful::Model::Actor::InstanceMethods

Defined in:
lib/timeful/model/actor.rb

Overview

rubocop:disable Style/Documentation

Instance Method Summary collapse

Instance Method Details

#publish_activity(action, object:) ⇒ Activity

Publishes an activity and creates a feed item for each subscriber.

Examples:

actor.publish_activity :post_created, object: post # => #<PostCreatedActivity>

Parameters:

  • action (Symbol)

    the action (or activity type) to create

  • object (ActiveRecord::Base)

    the object the action was taken upon

Returns:



22
23
24
25
# File 'lib/timeful/model/actor.rb', line 22

def publish_activity(action, object:)
  activity = activity_klass(action).create! object: object, actor: self
  DeliverActivityToSubscribersJob.perform_later activity
end