Class: TurboTest::ConstantTracer::EventPublisher

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Singleton
Defined in:
lib/turbo_test_constant_tracer/event_publisher.rb

Constant Summary collapse

EVENT =
"proxy_object_method_call"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEventPublisher

Returns a new instance of EventPublisher.



30
31
32
33
# File 'lib/turbo_test_constant_tracer/event_publisher.rb', line 30

def initialize
  @call_log = Concurrent::Map.new
  @log_all_events = false
end

Instance Attribute Details

#enabledObject (readonly)

Returns the value of attribute enabled.



13
14
15
# File 'lib/turbo_test_constant_tracer/event_publisher.rb', line 13

def enabled
  @enabled
end

Instance Method Details

#publish(name, location) ⇒ Object



47
48
49
50
51
52
# File 'lib/turbo_test_constant_tracer/event_publisher.rb', line 47

def publish(name, location)
  return unless @call_log[name].nil? || @log_all_events == true

  TurboTest::EventRegistry[EVENT].publish(name, location)
  @call_log[name] = true
end

#publish_all_events!Object



39
40
41
# File 'lib/turbo_test_constant_tracer/event_publisher.rb', line 39

def publish_all_events!
  @log_all_events = true
end

#publish_events_once!Object



43
44
45
# File 'lib/turbo_test_constant_tracer/event_publisher.rb', line 43

def publish_events_once!
  @log_all_events = false
end

#reset_call_logObject



35
36
37
# File 'lib/turbo_test_constant_tracer/event_publisher.rb', line 35

def reset_call_log
  @call_log.clear
end