Class: ASDeprecationTracker::Receiver

Inherits:
ActiveSupport::Subscriber
  • Object
show all
Defined in:
lib/as_deprecation_tracker/receiver.rb

Overview

Receives deprecation.rails events via ActiveSupport::Notifications

Instance Method Summary collapse

Constructor Details

#initializeReceiver

Returns a new instance of Receiver.



9
10
11
12
# File 'lib/as_deprecation_tracker/receiver.rb', line 9

def initialize
  super
  @event_queue = []
end

Instance Method Details

#deprecation(event) ⇒ Object



14
15
16
17
# File 'lib/as_deprecation_tracker/receiver.rb', line 14

def deprecation(event)
  @event_queue << event
  process_queue if ASDeprecationTracker.running?
end

#process_event(event) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/as_deprecation_tracker/receiver.rb', line 23

def process_event(event)
  return if ASDeprecationTracker.whitelist.matches?(event.payload)

  message = event.payload[:message]
  callstack = event.payload[:callstack].map(&:to_s)
  if ASDeprecationTracker.env('RECORD').present?
    write_deprecation(message, callstack)
  else
    raise_deprecation(message, callstack)
  end
end

#process_queueObject



19
20
21
# File 'lib/as_deprecation_tracker/receiver.rb', line 19

def process_queue
  process_event(@event_queue.pop) until @event_queue.empty?
end