class Utopia::Responder
Constants
- Handler
- Responds
Attributes
handlers[R]
Public Class Methods
new()
click to toggle source
# File lib/utopia/responder.rb, line 44 def initialize @handlers = HTTP::Accept::MediaTypes::Map.new end
Public Instance Methods
call(context, request, *arguments, **options)
click to toggle source
# File lib/utopia/responder.rb, line 56 def call(context, request, *arguments, **options) # Parse the list of browser preferred content types and return ordered by priority: media_types = HTTP::Accept::MediaTypes.browser_preferred_media_types(request.env) handler, media_range = @handlers.for(media_types) if handler handler.call(context, request, media_range, *arguments, **options) end end
freeze()
click to toggle source
Calls superclass method
# File lib/utopia/responder.rb, line 50 def freeze @handlers.freeze super end
handle(content_type, &block)
click to toggle source
Add a converter for the specified content type. Call the block with the response content if the request accepts the specified content_type.
# File lib/utopia/responder.rb, line 68 def handle(content_type, &block) @handlers << Handler.new(content_type, block) end
respond_to(context, request)
click to toggle source
# File lib/utopia/responder.rb, line 72 def respond_to(context, request) Responds.new(self, context, request) end