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, target:, meta: {}) ⇒ Activity

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

Examples:

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

Parameters:

  • action (Symbol)

    the action (or activity type) to create

  • target (ActiveRecord::Base)

    the target the action was taken upon

  • meta (Hash) (defaults to: {})

    any metadata to attach to the activity

Returns:



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

def publish_activity(action, target:, meta: {})
  activity = activity_klass(action).create! target: target, meta: meta, actor: self
  DeliverActivityToSubscribersJob.perform_later activity
end