Class: Heroku::Nav::Provider
- Inherits:
-
Base
- Object
- Base
- Heroku::Nav::Provider
show all
- Defined in:
- lib/heroku/nav.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
api_url, #call, #initialize, #refresh, resource, retry_upto
Class Method Details
.fetch ⇒ Object
123
124
125
|
# File 'lib/heroku/nav.rb', line 123
def fetch
super('text/html')
end
|
.html ⇒ Object
132
133
134
|
# File 'lib/heroku/nav.rb', line 132
def html
@@body ||= fetch
end
|
.resource_url ⇒ Object
127
128
129
|
# File 'lib/heroku/nav.rb', line 127
def resource_url
"#{api_url}/v1/providers/header"
end
|
Instance Method Details
#can_insert?(env) ⇒ Boolean
137
138
139
|
# File 'lib/heroku/nav.rb', line 137
def can_insert?(env)
super && env['HTTP_COOKIE'] && env['HTTP_COOKIE'].include?('heroku-nav-data')
end
|
#insert! ⇒ Object
141
142
143
144
145
146
147
148
149
|
# File 'lib/heroku/nav.rb', line 141
def insert!
if @nav
match = @body.match(/(\<body[^\>]*\>)/i)
if match && match.size > 0
@body.insert(match.end(0), @nav)
@headers['Content-Length'] = Rack::Utils.bytesize(@body).to_s
end
end
end
|