Class: ExceptionsBegone::Sender
- Inherits:
-
Object
- Object
- ExceptionsBegone::Sender
- Defined in:
- lib/exceptions_begone/sender.rb
Class Attribute Summary collapse
-
.mailer ⇒ Object
ugly.
Class Method Summary collapse
- .log(message) ⇒ Object
- .method_missing(method_name, *args) ⇒ Object
- .post(data, connection_options = {}) ⇒ Object
- .send_exception(exception, controller, request, connection_options = {}) ⇒ Object
- .send_generic(category, notification, connection_options = {}) ⇒ Object
Class Attribute Details
.mailer ⇒ Object
ugly
5 6 7 |
# File 'lib/exceptions_begone/sender.rb', line 5 def mailer @mailer end |
Class Method Details
.log(message) ⇒ Object
32 33 34 |
# File 'lib/exceptions_begone/sender.rb', line 32 def log() Rails.logger.error("[EXCEPTIONS_BEGONE]: #{}") end |
.method_missing(method_name, *args) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/exceptions_begone/sender.rb', line 36 def method_missing(method_name, *args) if method_name.to_s =~ /^send_(.*)/ Sender.__send__(:send_generic, "#{$1}", *args) else super(method_name, *args) end end |
.post(data, connection_options = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/exceptions_begone/sender.rb', line 7 def post(data, = {}) conn_conf = ConnectionConfigurator.build() http = Net::HTTP.new(conn_conf.host, conn_conf.port) http.read_timeout = conn_conf.read_timeout http.open_timeout = conn_conf.open_timeout log(data) http.post(conn_conf.path, data, "Content-type" => "application/json", "Accept" => "application/json") rescue TimeoutError, Errno::ECONNREFUSED => e log(e.inspect) log(data) mailer.deliver_error(e., "#{e.inspect} #{data}") if mailer end |
.send_exception(exception, controller, request, connection_options = {}) ⇒ Object
22 23 24 25 |
# File 'lib/exceptions_begone/sender.rb', line 22 def send_exception(exception, controller, request, = {}) notification = Formatter.format_exception_data(exception, controller, request) send_generic("exception", notification, = {}) end |
.send_generic(category, notification, connection_options = {}) ⇒ Object
27 28 29 30 |
# File 'lib/exceptions_begone/sender.rb', line 27 def send_generic(category, notification, = {}) data = Formatter.format_data(category, notification) post(data, ) end |