def handler(name, handler)
      # Construct an instance, if the handler is a class and needs to be initialized.
      handler = handler.new

      # Make sure it quacks like a handler.
      unless handler.respond_to?(:generate) && handler.respond_to?(:parse)
        raise ArgumentError, "Media type handlers must respond to #generate and #parse"
      end

      # Register that thing!
      @handlers[name.to_s] = handler
    end
def handler(name, handler)
      # Construct an instance, if the handler is a class and needs to be initialized.
      handler = handler.new

      # Make sure it quacks like a handler.
      unless handler.respond_to?(:generate) && handler.respond_to?(:parse)
        raise ArgumentError, "Media type handlers must respond to #generate and #parse"
      end

      # Register that thing!
      @handlers[name.to_s] = handler
    end
Register a media type handler used to transform medias' structured data
 to HTTP response entitites with a specific encoding (JSON, XML, etc)
 and to parse request bodies into structured data.

 @param [String] name
 @param [Class] a class that responds to .new, #parse and #generate