travis-api/lib/travis/api/app/responders/base.rb
Konstantin Haase 01ec5e152a Revert "instrument responders"
This reverts commit a8b1ccfc4a.
2015-01-14 18:07:40 +01:00

54 lines
894 B
Ruby

module Travis::Api::App::Responders
class Base
attr_reader :endpoint, :resource, :options
def initialize(endpoint, resource, options = {})
@endpoint = endpoint
@resource = resource
@options = options
end
def halt(*args)
endpoint.halt(*args)
end
def send_file(*args)
endpoint.send_file(*args)
end
def flash
endpoint.flash
end
def request
endpoint.request
end
def params
endpoint.params
end
def headers
endpoint.headers
end
def apply
endpoint.content_type content_type
end
def apply?
resource && acceptable_format?
end
def format
self.class.name.split('::').last.downcase
end
def acceptable_format?
if accept = options[:accept]
accept.accepts?(Rack::Mime.mime_type(".#{format}"))
end
end
end
end