Class: PryMoves::BindingsStack

Inherits:
Array
  • Object
show all
Defined in:
lib/pry-moves/bindings_stack.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ BindingsStack

Returns a new instance of BindingsStack.



3
4
5
6
7
8
9
10
11
12
# File 'lib/pry-moves/bindings_stack.rb', line 3

def initialize options
  @options = options
  bindings = binding.callers # binding_of_caller has bug and always returns callers of current binding,
    # no matter at which binding method is called. So no need to pass here binding
  pre_callers = Thread.current[:pre_callers]
  bindings = bindings + pre_callers if pre_callers
  concat remove_internal_frames(bindings)
  set_indices
  mark_vapid_frames
end

Instance Method Details

#fits_for_initial_frame(b) ⇒ Object



23
24
25
26
27
28
# File 'lib/pry-moves/bindings_stack.rb', line 23

def fits_for_initial_frame b
  PryMoves.step_in_everywhere or
    not b.hidden and (
      @options[:is_error] or b.eval("__method__") != :initialize
    )
end

#initial_frameObject



19
20
21
# File 'lib/pry-moves/bindings_stack.rb', line 19

def initial_frame
  find {|b| fits_for_initial_frame b}
end

#suggest_initial_frame_indexObject



14
15
16
17
18
# File 'lib/pry-moves/bindings_stack.rb', line 14

def suggest_initial_frame_index
  m = PryMoves::TracedMethod.last
  return 0 if m and m.binding_inside?(first)
  index {|b| fits_for_initial_frame b} || 0
end