Module: Sinatra::RPC::Serializer
- Extended by:
- Serializer
- Included in:
- Serializer
- Defined in:
- lib/sinatra/rpc/serializer.rb,
lib/sinatra/rpc/serializer/base.rb,
lib/sinatra/rpc/serializer/xmlrpc.rb
Overview
All the classes defined in this module represent serialization mechanisms for RPC requests/responses.
Defined Under Namespace
Instance Method Summary collapse
-
#find(content_type) ⇒ Class
Find the right Serializer::Base subclass for the given Content-Type HTTP request header.
-
#register(serializer_class, content_types) ⇒ Object
Add a serializer for a list of content types to the internal registry of Serializer classes.
Instance Method Details
#find(content_type) ⇒ Class
Find the right Serializer::Base subclass for the given Content-Type HTTP request header.
13 14 15 |
# File 'lib/sinatra/rpc/serializer.rb', line 13 def find(content_type) @registry[content_type] or @registry[nil] end |
#register(serializer_class, content_types) ⇒ Object
Add a serializer for a list of content types to the internal registry of Serializer classes.
19 20 21 22 23 24 |
# 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 |