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

 @return [Deferrable] Succeeds when the punsubscribe 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
   pattern (and therefore no punsubscription from redis is necessary)