Sha256: 18d088ffd2cc37545a369fabe0fee9f2996d8eca907f17a2c62951769a28f8ee
Contents?: true
Size: 1.07 KB
Versions: 75
Compression:
Stored size: 1.07 KB
Contents
# frozen_string_literal: true module Decidim module Comments # This is a helper class in order to publish comment creation events # so that components can react to these successes and perform whatever they are required to. class CommentCreation EVENT_NAME = "decidim.comments.comment_created" # Publishes the event to ActiveSupport::Notifications. # # comment - The Decidim::Comments::Comment that has just been created. # metadatas - The hash of metadatas returned by the ContentProcessor after parsing # this `comment`. def self.publish(comment, metadatas) ActiveSupport::Notifications.publish( EVENT_NAME, comment_id: comment.id, metadatas: metadatas ) end # Creates a subscription to events for created comments. # # block - The block to be executed when a comment is created. def self.subscribe(&block) ActiveSupport::Notifications.subscribe(EVENT_NAME) do |_event_name, data| block.call(data) end end end end end
Version data entries
75 entries across 75 versions & 1 rubygems