module Sinatra::RPC::Serializer

All the classes defined in this module represent serialization mechanisms for RPC requests/responses.

Public Instance Methods

find(content_type) click to toggle source

Find the right Serializer::Base subclass for the given Content-Type HTTP request header.

@param content_type [String] the value of the Content-Type header @return [Class] a Serializer class that can be used to

satisfy the request
# File lib/sinatra/rpc/serializer.rb, line 13
def find(content_type)
  @registry[content_type] or @registry[nil]
end
register(serializer_class, content_types) click to toggle source

Add a serializer for a list of content types to the internal registry of Serializer classes.

# File lib/sinatra/rpc/serializer.rb, line 19
def register(serializer_class, content_types)
  @registry ||= {}
  content_types.each do |c|
    @registry[c] = serializer_class
  end
end