Class: ActiveInteractionMapper::Filter::StartAt

Inherits:
Object
  • Object
show all
Defined in:
lib/active_interaction_mapper/filter/start_at.rb

Instance Method Summary collapse

Constructor Details

#initialize(start_matcher) ⇒ StartAt

Returns a new instance of StartAt.



4
5
6
7
8
# File 'lib/active_interaction_mapper/filter/start_at.rb', line 4

def initialize(start_matcher)
  @start_matcher = start_matcher
  @started = false
  @stack = []
end

Instance Method Details

#keep?(tp, normalized_class_name) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# 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