Class: CrashHook::Payload
- Inherits:
-
Object
- Object
- CrashHook::Payload
- Includes:
- Serializer
- Defined in:
- lib/crash_hook/payload.rb
Instance Attribute Summary collapse
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#exception ⇒ Object
readonly
Returns the value of attribute exception.
-
#extra_params ⇒ Object
readonly
Returns the value of attribute extra_params.
-
#framework ⇒ Object
readonly
Returns the value of attribute framework.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(exception, env, extra_params = {}) ⇒ Payload
constructor
Initialize a new CrashHook::Payload object exception => Exception object instance env => Environment hash extra_params => Additional parameters.
-
#to_hash ⇒ Object
Returns HASH representation of payload.
-
#to_json ⇒ Object
Returns JSON representation of payload.
-
#to_xml ⇒ Object
Returns XML representation of payload.
-
#to_yaml ⇒ Object
Returns YAML representation of payload.
Methods included from Serializer
#clean_non_serializable_data, #serializable?
Constructor Details
#initialize(exception, env, extra_params = {}) ⇒ Payload
Initialize a new CrashHook::Payload object
exception => Exception object instance
env => Environment hash
extra_params => Additional parameters
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/crash_hook/payload.rb', line 19 def initialize(exception, env, extra_params={}) @exception = { :class_name => exception.class.to_s, :message => exception., :backtrace => exception.backtrace, :timestamp => Time.now } @environment = clean_non_serializable_data(env) @version = CrashHook::VERSION @framework = 'rack' @framework = 'rails' if defined?(Rails) @framework = 'sinatra' if defined?(Sinatra) @extra_params = extra_params.kind_of?(Hash) ? extra_params : {} end |
Instance Attribute Details
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
9 10 11 |
# File 'lib/crash_hook/payload.rb', line 9 def environment @environment end |
#exception ⇒ Object (readonly)
Returns the value of attribute exception.
8 9 10 |
# File 'lib/crash_hook/payload.rb', line 8 def exception @exception end |
#extra_params ⇒ Object (readonly)
Returns the value of attribute extra_params.
12 13 14 |
# File 'lib/crash_hook/payload.rb', line 12 def extra_params @extra_params end |
#framework ⇒ Object (readonly)
Returns the value of attribute framework.
10 11 12 |
# File 'lib/crash_hook/payload.rb', line 10 def framework @framework end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
11 12 13 |
# File 'lib/crash_hook/payload.rb', line 11 def version @version end |
Instance Method Details
#to_hash ⇒ Object
Returns HASH representation of payload
36 37 38 39 40 41 42 43 |
# File 'lib/crash_hook/payload.rb', line 36 def to_hash { :exception => @exception, :environment => @environment, :version => @version, :framework => @framework } end |
#to_json ⇒ Object
Returns JSON representation of payload
47 48 49 50 51 |
# File 'lib/crash_hook/payload.rb', line 47 def to_json @extra_params.delete(:crash) @extra_params.delete('crash') MultiJson.encode({:crash => self.to_hash}.merge(@extra_params)) end |
#to_xml ⇒ Object
Returns XML representation of payload
61 62 63 |
# File 'lib/crash_hook/payload.rb', line 61 def to_xml # Not Implemented Yet end |
#to_yaml ⇒ Object
Returns YAML representation of payload
55 56 57 |
# File 'lib/crash_hook/payload.rb', line 55 def to_yaml YAML.dump({:crash => self.to_hash}) end |