Sha256: 4d885b1d157a551aa9a40336a910509621b799f0790e1bb35f947b375e5c0f25

Contents?: true

Size: 991 Bytes

Versions: 23

Compression:

Stored size: 991 Bytes

Contents

# frozen_string_literal: true

require_relative "async"

module ActionCable
  module SubscriptionAdapter
    # == Test adapter for Action Cable
    #
    # The test adapter should be used only in testing. Along with
    # ActionCable::TestHelper it makes a great tool to test your Rails application.
    #
    # To use the test adapter set +adapter+ value to +test+ in your +config/cable.yml+ file.
    #
    # NOTE: Test adapter extends the <tt>ActionCable::SubscriptionsAdapter::Async</tt> adapter,
    # so it could be used in system tests too.
    class Test < Async
      def broadcast(channel, payload)
        broadcasts(channel) << payload
        super
      end

      def broadcasts(channel)
        channels_data[channel] ||= []
      end

      def clear_messages(channel)
        channels_data[channel] = []
      end

      def clear
        @channels_data = nil
      end

      private
        def channels_data
          @channels_data ||= {}
        end
    end
  end
end

Version data entries

23 entries across 23 versions & 4 rubygems

Version Path
actioncable-7.0.8.6 lib/action_cable/subscription_adapter/test.rb
actioncable-7.0.8.5 lib/action_cable/subscription_adapter/test.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/actioncable-7.0.8.4/lib/action_cable/subscription_adapter/test.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/actioncable-7.0.5.1/lib/action_cable/subscription_adapter/test.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/actioncable-7.0.5.1/lib/action_cable/subscription_adapter/test.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/actioncable-7.0.5.1/lib/action_cable/subscription_adapter/test.rb
actioncable-7.0.8.4 lib/action_cable/subscription_adapter/test.rb
actioncable-7.0.8.1 lib/action_cable/subscription_adapter/test.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/actioncable-7.0.3.1/lib/action_cable/subscription_adapter/test.rb
actioncable-7.0.8 lib/action_cable/subscription_adapter/test.rb
actioncable-7.0.7.2 lib/action_cable/subscription_adapter/test.rb
actioncable-7.0.7.1 lib/action_cable/subscription_adapter/test.rb
actioncable-7.0.7 lib/action_cable/subscription_adapter/test.rb
actioncable-7.0.6 lib/action_cable/subscription_adapter/test.rb
actioncable-7.0.5.1 lib/action_cable/subscription_adapter/test.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/actioncable-7.0.3.1/lib/action_cable/subscription_adapter/test.rb
actioncable-7.0.5 lib/action_cable/subscription_adapter/test.rb
actioncable-7.0.4.3 lib/action_cable/subscription_adapter/test.rb
actioncable-7.0.4.2 lib/action_cable/subscription_adapter/test.rb
actioncable-7.0.4.1 lib/action_cable/subscription_adapter/test.rb