Class: RemoteNotifier::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/remote_notifier/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ Base

Returns a new instance of Base.



7
8
9
10
11
12
13
14
# File 'lib/remote_notifier/base.rb', line 7

def initialize(app, options = {})
  @app = app
  @remote = options[:remote]
  @token = options[:token]
  @secret = options[:secret]
  raise "Please provide :remote, :token and :secret when defining middleware" unless @remote && @token && @secret
  @remote += "/api/v1/"
end

Instance Attribute Details

#remoteObject

Returns the value of attribute remote.



5
6
7
# File 'lib/remote_notifier/base.rb', line 5

def remote
  @remote
end

#secretObject

Returns the value of attribute secret.



5
6
7
# File 'lib/remote_notifier/base.rb', line 5

def secret
  @secret
end

#tokenObject

Returns the value of attribute token.



5
6
7
# File 'lib/remote_notifier/base.rb', line 5

def token
  @token
end

Instance Method Details

#call(env) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/remote_notifier/base.rb', line 16

def call(env)
  begin
    @app.call(env)
  rescue Exception => exception
    RemoteNotifier::Notification.create(:backtrace => exception.backtrace.join("\n"), :msg_class => exception.class.to_s, :message => exception.message, :object => self)
    raise exception
  end
end