Sha256: e4a04b704d3658efc72ea51865db7787388cc26a6c755e97264b9eee7256f72c

Contents?: true

Size: 1013 Bytes

Versions: 46

Compression:

Stored size: 1013 Bytes

Contents

# Toplevel Pubnub module.
module Pubnub
  # Pubnub client Class
  class Client
    # Module that holds some helper methods
    module Helpers
      private

      def totally_empty(hash)
        hash.reduce(true) { |acc, (_, v)| acc && v.is_a?(Hash) ? totally_empty(v) : false }
      end

      def setup_pools
        # Event pool
        @env[:events] = []

        # Connection pools
        @env[:single_event_conn_pool] = {}
        @env[:subscribe_event_conn_pool] = {}
        @env[:heartbeat_event_conn_pool] = {}

        # Callback pools.
        @env[:c_cb_pool] = {}
        @env[:e_cb_pool] = {}

        # Subscription and heartbeat pools.
        @env[:subscription_pool] = {}
        @env[:heartbeat_pool] = {}

        # Requests pool.
        @env[:req_dispatchers_pool] = {}
        @env[:req_dispatchers_pool][:sync] = {}
        @env[:req_dispatchers_pool][:async] = {}
      end

      def clean_env
        @env.delete_if { |_, v| v.blank? } # nillify if blank
      end
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
pubnub-4.5.0 lib/pubnub/client/helpers.rb
pubnub-4.4.0 lib/pubnub/client/helpers.rb
pubnub-4.3.0 lib/pubnub/client/helpers.rb
pubnub-4.2.7 lib/pubnub/client/helpers.rb
pubnub-4.2.6 lib/pubnub/client/helpers.rb
pubnub-4.2.5 lib/pubnub/client/helpers.rb
pubnub-4.2.4 lib/pubnub/client/helpers.rb
pubnub-4.2.3 lib/pubnub/client/helpers.rb
pubnub-4.2.2 lib/pubnub/client/helpers.rb
pubnub-4.2.1 lib/pubnub/client/helpers.rb
pubnub-4.2.0 lib/pubnub/client/helpers.rb
pubnub-4.1.6 lib/pubnub/client/helpers.rb
pubnub-4.1.5 lib/pubnub/client/helpers.rb
pubnub-4.1.2 lib/pubnub/client/helpers.rb
pubnub-4.1.0 lib/pubnub/client/helpers.rb
pubnub-4.0.28 lib/pubnub/client/helpers.rb
pubnub-4.0.27 lib/pubnub/client/helpers.rb
pubnub-4.0.25 lib/pubnub/client/helpers.rb
pubnub-4.0.23 lib/pubnub/client/helpers.rb
pubnub-4.0.22 lib/pubnub/client/helpers.rb