lib/em-hiredis/pubsub_client.rb
def unsubscribe_proc(channel, proc)
      df = EM::DefaultDeferrable.new
      if @sub_callbacks[channel].delete(proc)
        if @sub_callbacks[channel].any?
          # Succeed deferrable immediately - no need to unsubscribe
          df.succeed
        else
          unsubscribe(channel).callback { |_|
            df.succeed
          }
        end
      else
        df.fail
      end
      return df
    end
def unsubscribe_proc(channel, proc)
      df = EM::DefaultDeferrable.new
      if @sub_callbacks[channel].delete(proc)
        if @sub_callbacks[channel].any?
          # Succeed deferrable immediately - no need to unsubscribe
          df.succeed
        else
          unsubscribe(channel).callback { |_|
            df.succeed
          }
        end
      else
        df.fail
      end
      return df
    end
Unsubscribe a given callback from a channel. Will unsubscribe from redis
 if there are no remaining subscriptions on this channel

 @return [Deferrable] Succeeds when the unsubscribe has completed or
   fails if callback could not be found. Note that success may happen
   immediately in the case that there are other callbacks for the same
   channel (and therefore no unsubscription from redis is necessary)