Class: Rack::Piwik
- Inherits:
-
Object
- Object
- Rack::Piwik
- Defined in:
- lib/rack/piwik.rb
Constant Summary collapse
- DEFAULT =
{}
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.
9 10 11 12 13 |
# File 'lib/rack/piwik.rb', line 9 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
17 18 19 20 21 22 23 |
# File 'lib/rack/piwik.rb', line 17 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
15 |
# File 'lib/rack/piwik.rb', line 15 def call(env); dup._call(env); end |