Class: Rack::Chartbeat
- Inherits:
-
Object
- Object
- Rack::Chartbeat
- Defined in:
- lib/rack/chartbeat.rb
Constant Summary collapse
- VERSION =
"0.0.3"
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Chartbeat
constructor
A new instance of Chartbeat.
Constructor Details
#initialize(app, options = {}) ⇒ Chartbeat
Returns a new instance of Chartbeat.
6 7 8 9 10 11 |
# File 'lib/rack/chartbeat.rb', line 6 def initialize(app, = {}) raise ArgumentError, "Chartbeat UID Required" unless [:uid] raise ArgumentError, "Domain Required" unless [:domain] && ![:domain].empty? @app, @options = app, end |
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rack/chartbeat.rb', line 13 def call(env) @status, @headers, @response = @app.call(env) return [@status, @headers, @response] unless html? response = Rack::Response.new([], @status, @headers) if @response.respond_to?(:to_ary) @response.each do |fragment| response.write inject_chartbeat(fragment) end end response.finish end |