1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actioncable/test/stubs/test_adapter.rb

22 lines
650 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class SuccessAdapter < ActionCable::SubscriptionAdapter::Base
2016-01-15 17:11:30 -05:00
def broadcast(channel, payload)
end
def subscribe(channel, callback, success_callback = nil)
subscriber_map[channel] << callback
2018-05-31 11:32:52 -04:00
@@subscribe_called = { channel: channel, callback: callback, success_callback: success_callback }
2016-01-15 17:11:30 -05:00
end
def unsubscribe(channel, callback)
subscriber_map[channel].delete(callback)
subscriber_map.delete(channel) if subscriber_map[channel].empty?
2018-05-31 11:32:52 -04:00
@@unsubscribe_called = { channel: channel, callback: callback }
2016-01-15 17:11:30 -05:00
end
def subscriber_map
@subscribers ||= Hash.new { |h, k| h[k] = [] }
end
2016-01-15 17:11:30 -05:00
end