Sha256: 3e835525e28f46490cb7c854451c56ff437a5bc6e37830f39501ff79ef7893b8

Contents?: true

Size: 814 Bytes

Versions: 2

Compression:

Stored size: 814 Bytes

Contents

require 'chillout/creation_listener'

module Chillout
  class Railtie < Rails::Railtie
    config.chillout = ActiveSupport::OrderedOptions.new
    initializer "chillout.exceptions_listener_initialization" do |app|
      if !app.config.chillout.empty?
        existing_option_keys = [:port, :hostname, :ssl].select{|key| app.config.chillout.has_key?(key)}
        options_list = existing_option_keys.map{|key| [key, app.config.chillout[key]]}
        options = Hash[options_list].merge(logger: Rails.logger)

        client = Client.new(app.config.chillout[:secret], options)

        ActiveRecord::Base.extend(CreationListener)

        app.middleware.use Middleware::ExceptionMonitor, client
        app.middleware.use Middleware::CreationsMonitor, client

        client.start_worker
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
chillout-0.2.3 lib/chillout/railtie.rb
chillout-0.2.2 lib/chillout/railtie.rb