class ActiveInteractionMapper::Filter::StartAt

Public Class Methods

new(start_matcher) click to toggle source
# File lib/active_interaction_mapper/filter/start_at.rb, line 4
def initialize(start_matcher)
  @start_matcher = start_matcher
  @started = false
  @stack = []
end

Public Instance Methods

keep?(tp, normalized_class_name) click to toggle source
# File lib/active_interaction_mapper/filter/start_at.rb, line 10
def keep?(tp, normalized_class_name)


  if !@started && call_event?(tp) && matches?(normalized_class_name)
    @started = true
  end

  if @started && call_event?(tp)
    @stack << normalized_class_name
    return true
  end

  if @started && return_event?(tp)
    @stack.pop

    if @stack.empty?
      @started = false
    end
  end

  @started
end

Private Instance Methods

call_event?(tp) click to toggle source
# File lib/active_interaction_mapper/filter/start_at.rb, line 35
def call_event?(tp)
  tp.event == :call || tp.event == :c_call
end
matches?(normalized_class_name) click to toggle source
# File lib/active_interaction_mapper/filter/start_at.rb, line 43
def matches?(normalized_class_name)
  case @start_matcher
  when Regexp
    (@start_matcher =~ normalized_class_name) != nil
  when String
    @start_matcher == normalized_class_name
  end
end
return_event?(tp) click to toggle source
# File lib/active_interaction_mapper/filter/start_at.rb, line 39
def return_event?(tp)
  tp.event == :return || tp.event == :c_return
end