Sha256: 643f16fbde6aa77bc5ca745b13375b351925fd433293f5c934a9217a95fc975a

Contents?: true

Size: 850 Bytes

Versions: 33

Compression:

Stored size: 850 Bytes

Contents

# frozen_string_literal: true

require_dependency "renalware"

module Renalware
  module Broadcasting
    include Wisper::Publisher
    extend ActiveSupport::Concern

    # Subscribes any listeners configured in Renalware.config.broadcast_subscription_map
    # to the current instance.
    #
    # Example usage
    #
    #   class SomeServiceObject
    #     include Broadcasting
    #
    #     def call
    #       ..
    #     end
    #   end
    #
    #   SomeServiceObject.new(..).broadcasting_to_configured_subscribers.call(..)
    #
    # See https://github.com/krisleech/wisper
    #
    def broadcasting_to_configured_subscribers
      subscribers = Renalware.config.broadcast_subscription_map[self.class.name]
      Array(subscribers).each{ |listener|
        subscribe(listener.to_s.constantize.new)
      }
      self
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
renalware-core-2.0.44 app/models/concerns/renalware/broadcasting.rb
renalware-core-2.0.43 app/models/concerns/renalware/broadcasting.rb
renalware-core-2.0.42 app/models/concerns/renalware/broadcasting.rb
renalware-core-2.0.41 app/models/concerns/renalware/broadcasting.rb
renalware-core-2.0.40 app/models/concerns/renalware/broadcasting.rb
renalware-core-2.0.39 app/models/concerns/renalware/broadcasting.rb
renalware-core-2.0.38 app/models/concerns/renalware/broadcasting.rb
renalware-core-2.0.37 app/models/concerns/renalware/broadcasting.rb
renalware-core-2.0.36 app/models/concerns/renalware/broadcasting.rb
renalware-core-2.0.35 app/models/concerns/renalware/broadcasting.rb
renalware-core-2.0.34 app/models/concerns/renalware/broadcasting.rb
renalware-core-2.0.33 app/models/concerns/renalware/broadcasting.rb
renalware-core-2.0.32 app/models/concerns/renalware/broadcasting.rb
renalware-core-2.0.31 app/models/concerns/renalware/broadcasting.rb
renalware-core-2.0.30 app/models/concerns/renalware/broadcasting.rb
renalware-core-2.0.28 app/models/concerns/renalware/broadcasting.rb
renalware-core-2.0.27 app/models/concerns/renalware/broadcasting.rb
renalware-core-2.0.26 app/models/concerns/renalware/broadcasting.rb
renalware-core-2.0.25 app/models/concerns/renalware/broadcasting.rb
renalware-core-2.0.24 app/models/concerns/renalware/broadcasting.rb