Sha256: 8ab7c0b0a6efd81c3cea174040f66736f85117a67fb005e1e861df9e3879a607

Contents?: true

Size: 1.79 KB

Versions: 1

Compression:

Stored size: 1.79 KB

Contents

module VoluntaryBrainstorming
  module Concerns
    module Model
      module Argument
        module PublishesChangesToBrainstorming
          extend ActiveSupport::Concern
          
          included do
            after_create :publish_create_to_brainstorming
            after_update :publish_update_to_brainstorming
            before_destroy :publish_destroy_to_brainstorming
            
            private
            
            def publish_create_to_brainstorming
              return if Rails.env.test? || Rails.env.cucumber?
              return unless argumentable_type == 'BrainstormingIdea'
              
              MessageBus.publish(
                "/brainstormings/#{argumentable.brainstorming.slug}", 
                { message: "#{I18n.t('arguments.model.publish_create_to_brainstorming')}: #{topic.name}" }
              )
            end
            
            def publish_update_to_brainstorming
              return if Rails.env.test? || Rails.env.cucumber?
              return unless argumentable_type == 'BrainstormingIdea'
              
              MessageBus.publish(
                "/brainstormings/#{argumentable.brainstorming.slug}", 
                { message: "#{I18n.t('arguments.model.publish_update_to_brainstorming')}: #{topic.name}" }
              )
            end
            
            def publish_destroy_to_brainstorming
              return if Rails.env.test? || Rails.env.cucumber?
              return unless argumentable_type == 'BrainstormingIdea'
              
              MessageBus.publish(
                "/brainstormings/#{argumentable.brainstorming.slug}", 
                { message: "#{I18n.t('arguments.model.publish_destroy_to_brainstorming')}: #{topic.name}" }
              )
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
voluntary_brainstorming-0.0.2 lib/voluntary_brainstorming/concerns/model/argument/publishes_changes_to_brainstorming.rb