lib/merb/mixins/responder_mixin.rb in merb-0.3.4 vs lib/merb/mixins/responder_mixin.rb in merb-0.3.7
- old
+ new
@@ -10,14 +10,14 @@
# type.yaml { @foo.to_yaml }
# end
module ResponderMixin
def respond_to(&block)
- responder = Rest::Responder.new(@env['HTTP_ACCEPT'], params)
+ responder = Rest::Responder.new(request.env['HTTP_ACCEPT'], params)
block.call(responder)
responder.respond(headers)
- @status = responder.status if responder.status
+ @_status = responder.status if responder.status
responder.body
end
module Rest
@@ -55,13 +55,11 @@
mime_type = negotiate_content
if mime_type
headers['Content-Type'] = mime_type.super_range
@body = @stack[mime_type.to_sym].call
else
- headers['Content-Type'] = nil
- @status = 406
- @body = nil
+ raise ControllerExceptions::NotAcceptable
end
end
protected
@@ -82,18 +80,18 @@
end
private
def negotiate_content
- if @params['format']
+ if @params[:format]
negotiate_by_format
elsif (@stack.keys & @accepts.map(&:to_sym)).size > 0
negotiate_by_accept_header
end
end
def negotiate_by_format
- format = @params['format'].to_sym
+ format = @params[:format].to_sym
if @stack[format]
if @accepts.map(&:to_sym).include?(format)
@accepts.detect{|a| a.to_sym == format }
else
AcceptType.new(TYPES[format].first,0)
\ No newline at end of file