Class: Rack::Piwik
- Inherits:
-
Object
- Object
- Rack::Piwik
- Defined in:
- lib/rack/piwik.rb
Constant Summary collapse
- DEFAULT =
{ :disable_cookies => false }
Instance Method Summary collapse
- #_call(env) ⇒ Object
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Piwik
constructor
A new instance of Piwik.
Constructor Details
#initialize(app, options = {}) ⇒ Piwik
Returns a new instance of Piwik.
11 12 13 14 15 16 |
# File 'lib/rack/piwik.rb', line 11 def initialize(app, = {}) raise ArgumentError, "piwik_url must be present" unless [:piwik_url] and ![:piwik_url].empty? raise ArgumentError, "piwik_id must be present" unless [:piwik_id] and ![:piwik_id].to_s.empty? @app, @options = app, DEFAULT.merge() end |
Instance Method Details
#_call(env) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/rack/piwik.rb', line 20 def _call(env) @status, @headers, @response = @app.call(env) return [@status, @headers, @response] unless html? response = Rack::Response.new([], @status, @headers) @response.each { |fragment| response.write inject(fragment) } response.finish end |
#call(env) ⇒ Object
18 |
# File 'lib/rack/piwik.rb', line 18 def call(env); dup._call(env); end |