Class: Raven::StacktraceInterface::Frame

Inherits:
Interface
  • Object
show all
Defined in:
lib/raven/interfaces/stack_trace.rb

Overview

Not actually an interface, but I want to use the same style

Instance Method Summary collapse

Methods inherited from Interface

#assert_required_properties_set!, name

Constructor Details

#initialize(*arguments) ⇒ Frame

Returns a new instance of Frame.



37
38
39
40
41
42
# File 'lib/raven/interfaces/stack_trace.rb', line 37

def initialize(*arguments)
  self.vars = {}
  self.pre_context = []
  self.post_context = []
  super(*arguments)
end

Instance Method Details

#filenameObject



44
45
46
47
48
49
# File 'lib/raven/interfaces/stack_trace.rb', line 44

def filename
  return nil if self.abs_path.nil?

  prefix = $LOAD_PATH.select { |s| self.abs_path.start_with?(s.to_s) }.sort_by { |s| s.to_s.length }.last
  prefix ? self.abs_path[prefix.chomp(File::SEPARATOR).length+1..-1] : self.abs_path
end

#to_hash(*args) ⇒ Object



51
52
53
54
55
56
57
58
59
# File 'lib/raven/interfaces/stack_trace.rb', line 51

def to_hash(*args)
  data = super(*args)
  data['filename'] = self.filename
  data.delete('vars') unless self.vars && !self.vars.empty?
  data.delete('pre_context') unless self.pre_context && !self.pre_context.empty?
  data.delete('post_context') unless self.post_context && !self.post_context.empty?
  data.delete('context_line') unless self.context_line && !self.context_line.empty?
  data
end