Class: SimpleEmailExceptionNotifier::Message
- Inherits:
-
Object
- Object
- SimpleEmailExceptionNotifier::Message
- Defined in:
- lib/simple_email_exception_notifier/message.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(formatter = Formatter.new) ⇒ Message
constructor
A new instance of Message.
- #print_request(request) ⇒ Object
- #print_section(title, details) ⇒ Object
- #print_summary(exception) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(formatter = Formatter.new) ⇒ Message
Returns a new instance of Message.
5 6 7 8 |
# File 'lib/simple_email_exception_notifier/message.rb', line 5 def initialize(formatter = Formatter.new) @content = [] @formatter = formatter end |
Class Method Details
.compose(formatter = Formatter.new, &block) ⇒ Object
10 11 12 13 14 |
# File 'lib/simple_email_exception_notifier/message.rb', line 10 def self.compose(formatter = Formatter.new, &block) = self.new(formatter) block.call() .to_s end |
Instance Method Details
#print_request(request) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/simple_email_exception_notifier/message.rb', line 22 def print_request(request) print_section('Request', url: request.url, http_method: request.request_method, ip_address: request.ip, parameters: request.params, server: Socket.gethostname ) end |
#print_section(title, details) ⇒ Object
32 33 34 |
# File 'lib/simple_email_exception_notifier/message.rb', line 32 def print_section(title, details) content << formatter.section(title, details) end |
#print_summary(exception) ⇒ Object
16 17 18 19 20 |
# File 'lib/simple_email_exception_notifier/message.rb', line 16 def print_summary(exception) opening_line = "#{exception.class} occurred at #{Time.now.utc} :" content << formatter.text(opening_line) content << formatter.text(exception.) end |
#to_s ⇒ Object
36 37 38 |
# File 'lib/simple_email_exception_notifier/message.rb', line 36 def to_s content.flatten.join("\n") end |