Class: Exceptional::ExceptionData
- Inherits:
-
Object
- Object
- Exceptional::ExceptionData
- Defined in:
- lib/exceptional/exception_data.rb
Instance Attribute Summary collapse
-
#language ⇒ Object
readonly
Returns the value of attribute language.
Instance Method Summary collapse
-
#initialize ⇒ ExceptionData
constructor
A new instance of ExceptionData.
- #to_hash ⇒ Object
- #to_json ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize ⇒ ExceptionData
Returns a new instance of ExceptionData.
18 19 20 21 22 23 |
# File 'lib/exceptional/exception_data.rb', line 18 def initialize environment = {} session = {} parameters = {} @language = ::LANGUAGE end |
Instance Attribute Details
#language ⇒ Object (readonly)
Returns the value of attribute language.
16 17 18 |
# File 'lib/exceptional/exception_data.rb', line 16 def language @language end |
Instance Method Details
#to_hash ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/exceptional/exception_data.rb', line 31 def to_hash hash = {} ::ATTRS.each do |attribute| value = send(attribute) hash[attribute] = value unless (value.nil? || value.empty? || attribute.is_a?(TCPSocket) || attribute.is_a?(TCPServer)) end hash end |
#to_json ⇒ Object
40 41 42 |
# File 'lib/exceptional/exception_data.rb', line 40 def to_json self.to_hash.to_json end |
#valid? ⇒ Boolean
25 26 27 28 29 |
# File 'lib/exceptional/exception_data.rb', line 25 def valid? ::BASE_ATTRS.each do |method| raise(DataError, "base data #{method} not set") if (self.send(method).nil? || self.send(method).empty?) end end |