Sha256: d993f383cfc15f00ccda399b50556e045df4d82a00e85ae857528f5abe40cde3

Contents?: true

Size: 810 Bytes

Versions: 2

Compression:

Stored size: 810 Bytes

Contents

require 'chillout/creation_listener'

module Chillout
  class Railtie < Rails::Railtie
    config.chillout = ActiveSupport::OrderedOptions.new
    initializer "chillout.creations_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::CreationsMonitor, client

        client.start_worker
      end
    end

    rake_tasks do
      load "chillout/tasks.rb"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
chillout-0.5.0 lib/chillout/railtie.rb
chillout-0.4.1 lib/chillout/railtie.rb