Class: Subscene::Response

Inherits:
Faraday::Response::Middleware
  • Object
show all
Defined in:
lib/subscene/response.rb

Direct Known Subclasses

HTML

Defined Under Namespace

Classes: HTML, RaiseError

Constant Summary collapse

CONTENT_TYPE =
'Content-Type'.freeze

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.parserObject

Returns the value of attribute parser


6
7
8
# File 'lib/subscene/response.rb', line 6

def parser
  @parser
end

Class Method Details

.define_parser(&block) ⇒ Object

Store a Proc that receives the body and returns the parsed result.


10
11
12
# File 'lib/subscene/response.rb', line 10

def self.define_parser(&block)
  @parser = block
end

Instance Method Details

#parse_response?(env) ⇒ Boolean


18
19
20
# File 'lib/subscene/response.rb', line 18

def parse_response?(env)
  env[:body].respond_to? :to_str
end

#response_type(env) ⇒ Object


14
15
16
# File 'lib/subscene/response.rb', line 14

def response_type(env)
  env[:response_headers][CONTENT_TYPE].to_s
end