Class: Exceptional::ExceptionData

Inherits:
Object
  • Object
show all
Defined in:
lib/exceptional/exception_data.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeExceptionData

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

#languageObject (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_hashObject



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_jsonObject



40
41
42
# File 'lib/exceptional/exception_data.rb', line 40

def to_json
  self.to_hash.to_json
end

#valid?Boolean

Returns:

  • (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