Sha256: 6f1f4f2f4b6d817e8de33b7f0d5951e80dc761f7827b300831e6b8c1f672985b

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

require 'set'
require 'wisper/version'
require 'wisper/publisher'
require 'wisper/registration/registration'
require 'wisper/registration/object'
require 'wisper/registration/block'
require 'wisper/global_listeners'
require 'wisper/temporary_listeners'

module Wisper
  def self.included(base)
    warn "[DEPRECATION] `include Wisper::Publisher` instead of `include Wisper`"
    base.class_eval { include Wisper::Publisher  }
  end

  def self.with_listeners(*args, &block)
    warn "[DEPRECATION] `use Wisper.subscribe` instead of `Wisper.with_listeners`"
    self.subscribe(*args, &block)
  end

  def self.add_listener(listener, options = {})
    warn "[DEPRECATION] `use Wisper.subscribe` instead of `Wisper.add_listener`"
    self.subscribe(listener, options)
  end

  def self.subscribe(*args, &block)
    if block_given?
      TemporaryListeners.with(*args, &block)
    else
      options = args.last.is_a?(Hash) ? args.pop : {}
      args.each do |listener|
        GlobalListeners.add(listener, options)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wisper-1.4.0 lib/wisper.rb