Class: Bullet::Rack
Instance Method Summary
collapse
Methods included from Dependency
#active_record30?, #active_record31?, #active_record32?, #active_record3?, #active_record40?, #active_record41?, #active_record42?, #active_record4?, #active_record?, #active_record_version, #mongoid2x?, #mongoid3x?, #mongoid4x?, #mongoid?, #mongoid_version, #rails?
Constructor Details
#initialize(app) ⇒ Rack
Returns a new instance of Rack.
5
6
7
|
# File 'lib/bullet/rack.rb', line 5
def initialize(app)
@app = app
end
|
Instance Method Details
#append_to_html_body(response_body, content) ⇒ Object
44
45
46
47
48
49
50
51
|
# File 'lib/bullet/rack.rb', line 44
def append_to_html_body(response_body, content)
if response_body.include?('</body>')
position = response_body.rindex('</body>')
response_body.insert(position, content)
else
response_body << content
end
end
|
#empty?(response) ⇒ Boolean
fix issue if response’s body is a Proc
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/bullet/rack.rb', line 31
def empty?(response)
if rails?
(response.is_a?(Array) && response.size <= 1) ||
!response.respond_to?(:body) ||
!response_body(response).respond_to?(:empty?) ||
response_body(response).empty?
else
body = response_body(response)
body.nil? || body.empty?
end
end
|
#file?(headers) ⇒ Boolean
57
58
59
|
# File 'lib/bullet/rack.rb', line 57
def file?()
["Content-Transfer-Encoding"] == "binary"
end
|
53
54
55
|
# File 'lib/bullet/rack.rb', line 53
def
"<div #{}>" + Bullet..uniq.join("<br>") + "</div>"
end
|
#html_request?(headers, response) ⇒ Boolean
65
66
67
|
# File 'lib/bullet/rack.rb', line 65
def html_request?(, response)
['Content-Type'] && ['Content-Type'].include?('text/html') && response_body(response).include?("<html")
end
|
#response_body(response) ⇒ Object
69
70
71
72
73
74
75
|
# File 'lib/bullet/rack.rb', line 69
def response_body(response)
if rails?
Array === response.body ? response.body.first : response.body
else
response.first
end
end
|
#sse?(headers) ⇒ Boolean
61
62
63
|
# File 'lib/bullet/rack.rb', line 61
def sse?()
["Content-Type"] == "text/event-stream"
end
|