class Vizsla::Subscribers

Public Class Methods

new() click to toggle source
# File lib/vizsla/subscribers.rb, line 70
def initialize
  @events_data = Recorder
  collect_events_data
end

Public Instance Methods

collect_events_data() click to toggle source

—————————===

Aux

—————————===

# File lib/vizsla/subscribers.rb, line 116
def collect_events_data
  sql_hook
  process_action_hook
  render_template_hook
  postgres_hook
end
postgres_hook() click to toggle source

—————————===

Non-Rails Hooks

—————————===

# File lib/vizsla/subscribers.rb, line 103
def postgres_hook
  unless rails_app?
    ::Vizsla::Patches.patch_postgres do |event_data|
      event = SQLEvent.new event_data
      @events_data << event
    end
  end
end
process_action_hook() click to toggle source
# File lib/vizsla/subscribers.rb, line 83
def process_action_hook
  return unless rails_app?
  ActiveSupport::Notifications.subscribe "process_action.action_controller" do |*args|
    event = ControllerEvent.new(args)
    @events_data << event
  end
end
render_template_hook() click to toggle source
# File lib/vizsla/subscribers.rb, line 91
def render_template_hook
  return unless rails_app?
  ActiveSupport::Notifications.subscribe "render_template.action_view" do |*args|
    event = ViewEvent.new(args)
    @events_data << event
  end
end
report_events_data() click to toggle source
# File lib/vizsla/subscribers.rb, line 123
def report_events_data
  @logger.log_events(@events_data)
end
sql_hook() click to toggle source
# File lib/vizsla/subscribers.rb, line 75
def sql_hook
  return unless rails_app?
  ActiveSupport::Notifications.subscribe "sql.active_record" do |*args|
    event = SQLEvent.new(args)
    @events_data << event if event.valid?
  end
end

Private Instance Methods

rails_app?() click to toggle source
# File lib/vizsla/subscribers.rb, line 129
def rails_app?
  defined? ::Rails
end