Sha256: 4bf523b125df9c2cefe658f67916f9d1ab255197b349ef819fd721ef9bce3ba7

Contents?: true

Size: 638 Bytes

Versions: 5

Compression:

Stored size: 638 Bytes

Contents

module Tim
  class CustomResponder < ActionController::Responder
    # We want different API Behaviour than in default renderer
    def api_behavior(error)
      raise error unless resourceful?

      status = :ok
      begin
        if get? then
          display resource
        elsif post?
          status = :created
          controller.render :status => status, :action => "show"
        elsif put?
          controller.render :status => :ok, :action => "show"
        else
          head :no_content
        end
      rescue ActionView::MissingTemplate => e
        display resource, :status => status
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
tim-0.3.0 app/responders/tim/custom_responder.rb
tim-0.2.0 app/responders/tim/custom_responder.rb
tim-0.1.2 app/responders/tim/custom_responder.rb
tim-0.1.1 app/responders/tim/custom_responder.rb
tim-0.0.1 app/responders/tim/custom_responder.rb