Sha256: eddb24e9bfdae6a97828977e4f1d77ee033eeca90dfb905342dcfdd9fd863196

Contents?: true

Size: 746 Bytes

Versions: 22

Compression:

Stored size: 746 Bytes

Contents

# Toplevel Pubnub module.
module Pubnub
  # SubscribeCallback class holds infrastructure for subscribe callbacks
  class SubscribeCallback
    attr_accessor :callbacks

    def initialize(options)
      @callbacks = {
        message: options[:message],
        status: options[:status],
        presence: options[:presence],
        signal: options[:signal],
        object: options[:object]
      }
      validate!
    end

    private

    def validate!
      # Check if each callback responds to call and accept one parameter.
      @callbacks.each do |type, callback|
        raise "#{type} callback is not valid in SubscribeCallback." unless (callback.respond_to?(:call) && callback.arity == 1) || callback.nil?
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
pubnub-5.4.0 lib/pubnub/subscribe_callback.rb
pubnub-5.3.5 lib/pubnub/subscribe_callback.rb
pubnub-5.3.4 lib/pubnub/subscribe_callback.rb
pubnub-5.3.3 lib/pubnub/subscribe_callback.rb
pubnub-5.3.2 lib/pubnub/subscribe_callback.rb
pubnub-5.3.1 lib/pubnub/subscribe_callback.rb
pubnub-5.3.0 lib/pubnub/subscribe_callback.rb
pubnub-5.2.2 lib/pubnub/subscribe_callback.rb
pubnub-5.2.1 lib/pubnub/subscribe_callback.rb
pubnub-5.2.0 lib/pubnub/subscribe_callback.rb
pubnub-5.1.2 lib/pubnub/subscribe_callback.rb
pubnub-5.1.1 lib/pubnub/subscribe_callback.rb
pubnub-5.1.0 lib/pubnub/subscribe_callback.rb
pubnub-5.0.0 lib/pubnub/subscribe_callback.rb
pubnub-4.8.0 lib/pubnub/subscribe_callback.rb
pubnub-4.7.1 lib/pubnub/subscribe_callback.rb
pubnub-4.7.0 lib/pubnub/subscribe_callback.rb
pubnub-4.6.2 lib/pubnub/subscribe_callback.rb
pubnub-4.6.1 lib/pubnub/subscribe_callback.rb
pubnub-4.6.0 lib/pubnub/subscribe_callback.rb