module Spine::Actions::Responder
Public Instance Methods
build_url(url, data)
click to toggle source
# File lib/spine/actions/responder.rb, line 48 def build_url(url, data) uri = URI(url) query = URI.decode_www_form(uri.query || '') || [] uri.query = URI.encode_www_form(query + data.to_a) uri.to_s end
finish_response()
click to toggle source
# File lib/spine/actions/responder.rb, line 43 def finish_response @responded = true response end
redirect(url, options = {})
click to toggle source
# File lib/spine/actions/responder.rb, line 33 def redirect(url, options = {}) response[Rack::CONTENT_TYPE] = 'application/x-www-form-urlencoded' response.redirect( build_url(url, options.fetch(:data, {})), options.fetch(:status, 302) ) finish_response end
respond(content, options = {})
click to toggle source
# File lib/spine/actions/responder.rb, line 11 def respond(content, options = {}) response[Rack::CONTENT_TYPE] = options.fetch(:content_type) { format.mime_type } response.status = options[:status] if options[:status] response.write(format.dump(content)) finish_response end
responded?()
click to toggle source
# File lib/spine/actions/responder.rb, line 7 def responded? @responded end
send_data(binary, options = {})
click to toggle source
# File lib/spine/actions/responder.rb, line 21 def send_data(binary, options = {}) response['Content-Transfer-Encoding'] = 'binary' response[Rack::CONTENT_TYPE] = options.fetch(:content_type, 'application/octet-stream') if options[:filename] response['Content-Disposition'] = "inline; filename='#{ options[:filename] }'" end response.write(binary) finish_response end