Class: Errordite::Serializer
- Inherits:
-
Object
- Object
- Errordite::Serializer
- Defined in:
- lib/errordite/serializer.rb
Constant Summary collapse
- SPECIAL_CONTEXT_ATTRIBUTES =
['MachineName', 'Url', 'UserAgent', 'Version']
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#exception ⇒ Object
readonly
Returns the value of attribute exception.
Instance Method Summary collapse
- #as_json ⇒ Object
-
#initialize(exception, context = {}) ⇒ Serializer
constructor
A new instance of Serializer.
- #to_json ⇒ Object
Constructor Details
#initialize(exception, context = {}) ⇒ Serializer
Returns a new instance of Serializer.
9 10 11 12 |
# File 'lib/errordite/serializer.rb', line 9 def initialize(exception, context = {}) @exception = exception @context = context end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
7 8 9 |
# File 'lib/errordite/serializer.rb', line 7 def context @context end |
#exception ⇒ Object (readonly)
Returns the value of attribute exception.
7 8 9 |
# File 'lib/errordite/serializer.rb', line 7 def exception @exception end |
Instance Method Details
#as_json ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/errordite/serializer.rb', line 14 def as_json special_attributes.merge( "Token" => Errordite.api_token, "TimestampUtc" => Time.now.strftime("%Y-%m-%d %H:%M:%S"), "ExceptionInfo" => { "Source" => source, "Message" => exception., "MethodName" => method_name, "ExceptionType" => exception.class.name, "StackTrace" => stack_trace, "Data" => exception_data } ) end |
#to_json ⇒ Object
29 30 31 |
# File 'lib/errordite/serializer.rb', line 29 def to_json JSON.dump(as_json) end |