Sha256: 0bce6c5dc58c61155c1deb9dd1cd5c2e89d719619c8797539706d029579e1a2e
Contents?: true
Size: 1.38 KB
Versions: 11
Compression:
Stored size: 1.38 KB
Contents
require 'hashie' require 'opbeat/interfaces' module Opbeat class StacktraceInterface < Interface name 'stacktrace' property :frames, :default => [] def initialize(*arguments) self.frames = [] super(*arguments) end def to_hash data = super data['frames'] = data['frames'].map{|frame| frame.to_hash} data end def frame(attributes=nil, &block) Frame.new(attributes, &block) end # Not actually an interface, but I want to use the same style class Frame < Interface property :abs_path property :filename, :required => true property :function property :vars property :pre_context property :post_context property :context_line property :lineno, :required => true def initialize(*arguments) self.vars= {} self.pre_context = [] self.post_context = [] super(*arguments) end def to_hash data = super 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 end end register_interface :stack_trace => StacktraceInterface end
Version data entries
11 entries across 11 versions & 1 rubygems