class Nexaas::Auditor::Subscriber

Public Class Methods

pattern() click to toggle source
# File lib/nexaas/auditor/subscriber.rb, line 21
def self.pattern
  raise "Not Implemented, override in subclass and provide a regex or string."
end
subscribe(options={}) click to toggle source
# File lib/nexaas/auditor/subscriber.rb, line 16
def self.subscribe(options={})
  subscriber = options.fetch(:subscriber) { ::ActiveSupport::Notifications }
  subscriber.subscribe(pattern, new)
end
subscribe_all() click to toggle source
# File lib/nexaas/auditor/subscriber.rb, line 7
def self.subscribe_all
  validate_subclasses!
  subscribers = []
  subclasses.each do |klass|
    subscribers << klass.subscribe()
  end
  subscribers
end

Private Class Methods

validate_subclasses!() click to toggle source

raise error if no app-level subclasses (of StatsSubscriber and LogsSubscriber) are found.

# File lib/nexaas/auditor/subscriber.rb, line 41
def self.validate_subclasses!
  raise RuntimeError,
    "no subclasses of #{self} found!" if subclasses.empty?
end

Public Instance Methods

call(name, start, finish, event_id, payload) click to toggle source

Dispatcher that converts incoming events to method calls.

# File lib/nexaas/auditor/subscriber.rb, line 26
def call(name, start, finish, event_id, payload)
  method_name = event_method_name(name)
  if respond_to?(method_name)
    send(method_name, name, start, finish, event_id, payload)
  end
end

Private Instance Methods

event_method_name(name) click to toggle source
# File lib/nexaas/auditor/subscriber.rb, line 35
def event_method_name(name)
  raise "Not Implemented, override in subclass."
end