Class: Rack::Lilypad

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/lilypad.rb,
lib/rack/lilypad/rails.rb

Defined Under Namespace

Modules: Rails Classes: Hoptoad

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, api_key = nil) {|_self| ... } ⇒ Lilypad

Returns a new instance of Lilypad.

Yields:

  • (_self)

Yield Parameters:

  • _self (Rack::Lilypad)

    the object that the method was called on



11
12
13
14
15
16
17
18
# File 'lib/rack/lilypad.rb', line 11

def initialize(app, api_key = nil)
  @app = app
  @filters = []
  @log = false
  yield self if block_given?
  @filters.flatten!
  @@hoptoad = @hoptoad = Hoptoad.new(api_key, @filters, @log)
end

Instance Attribute Details

#filtersObject

Returns the value of attribute filters.



8
9
10
# File 'lib/rack/lilypad.rb', line 8

def filters
  @filters
end

#logObject

Returns the value of attribute log.



9
10
11
# File 'lib/rack/lilypad.rb', line 9

def log
  @log
end

Class Method Details

.notify(e) ⇒ Object



34
35
36
# File 'lib/rack/lilypad.rb', line 34

def notify(e)
  @@hoptoad.post(e)
end

.production?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/rack/lilypad.rb', line 38

def production?
  %w(staging production).include?(ENV['RACK_ENV'])
end

Instance Method Details

#call(env) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rack/lilypad.rb', line 20

def call(env)
  status, headers, body =
    begin
      @app.call(env)
    rescue Exception => e
      @hoptoad.post(e, env)
      raise
    end
  @hoptoad.post(env['rack.exception'], env) if env['rack.exception']
  [ status, headers, body ]
end