module AnyCable::Compatibility

def __anycable_check_ivars__

def __anycable_check_ivars__
  was_ivars = instance_variables
  res = yield
  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
  unless diff.empty?
    raise AnyCable::CompatibilityError,
      "Channel instance variables are not supported by AnyCable, " \
      "but were set: #{diff.join(", ")}"
  end
  res
end

def periodically(*)

def periodically(*)
  raise AnyCable::CompatibilityError, "Periodical timers are not supported by AnyCable"
end

def stream_from(broadcasting, callback = nil, coder: nil)

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
  if callback.present? || block_given?
    raise AnyCable::CompatibilityError,
      "Custom stream callbacks are not supported by AnyCable"
  end
  super
end