Contains methods and attributes that act on the response returned from the request
Defined Under NamespaceClasses: AtomParser, FollowRedirects, Header, Jsonize, Mashify, RaiseError, Xmlize
Constant Summary collapse'Content-Type'.freeze
Returns the value of attribute parser.
A new instance of Response.
Returns a new instance of Response.
19 20 21 22
# File 'lib/github_api/response.rb', line 19 def initialize(app, options = {}) super(app) @content_types = Array(options[:content_type]) endClass Attribute Details .parser ⇒ Object
Returns the value of attribute parser.
12 13 14
# File 'lib/github_api/response.rb', line 12 def parser @parser endClass Method Details .define_parser(&block) ⇒ Object
15 16 17
# File 'lib/github_api/response.rb', line 15 def self.define_parser(&block) @parser = block endInstance Method Details #parse_body?(env) ⇒ Boolean
28 29 30
# File 'lib/github_api/response.rb', line 28 def parse_body?(env) parse_response_type?(response_type(env)) and parse_response?(env) end#parse_response?(env) ⇒ Boolean
44 45 46
# File 'lib/github_api/response.rb', line 44 def parse_response?(env) env[:body].respond_to?(:to_str) end#parse_response_type?(type) ⇒ Boolean
38 39 40 41 42
# File 'lib/github_api/response.rb', line 38 def parse_response_type?(type) @content_types.empty? || @content_types.any? { |pattern| pattern.is_a?(Regexp) ? type =~ pattern : type == pattern } end#process_body(env) ⇒ Object
24 25 26
# File 'lib/github_api/response.rb', line 24 def process_body(env) env[:body] = parse(env[:body]) end#response_type(env) ⇒ Object
32 33 34 35 36
# File 'lib/github_api/response.rb', line 32 def response_type(env) type = env[:response_headers][CONTENT_TYPE].to_s type = type.split(';', 2).first if type.index(';') type end
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4