Sha256: c446223c321b0e5433834478a849e66015274a7219ca4fadb4f2fc5842459ccb

Contents?: true

Size: 675 Bytes

Versions: 1

Compression:

Stored size: 675 Bytes

Contents

module Waku
  module Trackable
    extend ActiveSupport::Concern
  
    included do
      include PublicActivity::Model
    end
  
    def create_notification(owner:, recipient: nil, key:, params: {})
      return if owner.blank?
      notification = Activity.new(trackable: self, key: key)
  
      raise Activity::AcitivityTypeError unless notification.valid_trackable?
  
      data = { owner: owner, parameters: params, recipient: recipient, group: group_activity }
      data.each { |key, value| notification.send("#{key}=", value)}
      notification.save!
    end
  
    private
  
    def group_activity
      return id if is_a?(Post)
      post_id
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
waku-0.1.2 lib/waku/activity/trackable.rb