lib/anycable/rails/compatibility.rb in anycable-rails-1.0.5 vs lib/anycable/rails/compatibility.rb in anycable-rails-1.0.7

- old
+ new

@@ -2,10 +2,15 @@ module AnyCable class CompatibilityError < StandardError; end module Compatibility # :nodoc: + IGNORE_INSTANCE_VARS = %i[ + @active_periodic_timers + @_streams + ] + ActionCable::Channel::Base.prepend(Module.new do def stream_from(broadcasting, callback = nil, coder: nil) if coder.present? && coder != ActiveSupport::JSON raise AnyCable::CompatibilityError, "Custom coders are not supported by AnyCable" end @@ -21,20 +26,18 @@ # Do not prepend `subscribe_to_channel` 'cause we make it no-op # when AnyCable is running (see anycable/rails/actioncable/channel.rb) %w[run_callbacks perform_action].each do |mid| module_eval <<~CODE, __FILE__, __LINE__ + 1 def #{mid}(*) - # allocate @_streams - streams __anycable_check_ivars__ { super } end CODE end def __anycable_check_ivars__ was_ivars = instance_variables res = yield - diff = instance_variables - was_ivars + diff = instance_variables - was_ivars - IGNORE_INSTANCE_VARS if self.class.respond_to?(:channel_state_attributes) diff.delete(:@__istate__) diff.delete_if { |ivar| self.class.channel_state_attributes.include?(:"#{ivar.to_s.sub(/^@/, "")}") } end