Sha256: 4a24a54a2f91f98b98fab2bdee97759b1ab683c1e743ebf3d66ee7d75ca2bf46

Contents?: true

Size: 819 Bytes

Versions: 27

Compression:

Stored size: 819 Bytes

Contents

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

27 entries across 27 versions & 1 rubygems

Version Path
renalware-core-2.0.0.pre.beta11 app/models/concerns/renalware/broadcasting.rb
renalware-core-2.0.0.pre.beta10 app/models/concerns/renalware/broadcasting.rb
renalware-core-2.0.0.pre.beta9 app/models/concerns/renalware/broadcasting.rb
renalware-core-2.0.0.pre.beta8 app/models/concerns/renalware/broadcasting.rb
renalware-core-2.0.0.pre.beta7 app/models/concerns/renalware/broadcasting.rb
renalware-core-2.0.0.pre.beta6 app/models/concerns/renalware/broadcasting.rb
renalware-core-2.0.0.pre.beta5 app/models/concerns/renalware/broadcasting.rb