Class: RShade::Stack

Inherits:
Object show all
Defined in:
lib/rshade/stack.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config: nil, registry: ::RShade::Config::Registry.instance) ⇒ Stack

Returns a new instance of Stack.



7
8
9
# File 'lib/rshade/stack.rb', line 7

def initialize(config: nil, registry: ::RShade::Config::Registry.instance)
  @config = config || registry.default_stack_config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



5
6
7
# File 'lib/rshade/stack.rb', line 5

def config
  @config
end

Class Method Details

.trace(config: nil) ⇒ Object



11
12
13
# File 'lib/rshade/stack.rb', line 11

def self.trace(config: nil)
  new(config: config).trace
end

Instance Method Details

#traceObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/rshade/stack.rb', line 15

def trace
  config.exclude_gems!
  result = binding.callers.drop(2).map do |bind|
    frame = StackFrame.from_binding(bind)
    next nil unless config.filter.call(frame)

    frame
  end.compact.reverse
  config.formatter.call(result, variable_serializer: config.variable_serializer)
end