Sha256: 8046cb1b962ad54978862b1e6e3dd07fbf4b0bfb084e0135d359b6a6ca67e295
Contents?: true
Size: 1.41 KB
Versions: 2
Compression:
Stored size: 1.41 KB
Contents
require 'chillout/creation_listener' module Chillout class Railtie < Rails::Railtie config.chillout = ActiveSupport::OrderedOptions.new initializer "chillout.creations_listener_initialization" do |rails_app| chillout_config = rails_app.config.chillout if !chillout_config.empty? RailsInitializer.new(rails_app, chillout_config, Rails.logger).start end end rake_tasks do load "chillout/tasks.rb" end end class RailsInitializer def initialize(rails_app, chillout_config, rails_logger) @rails_app = rails_app @chillout_config = chillout_config @rails_logger = rails_logger end def start @rails_logger.info "[Chillout] railtie initializing" client = Client.new(@chillout_config[:secret], options) ActiveRecord::Base.extend(CreationListener) @rails_logger.info "[Chillout] creation listener attached" @rails_app.middleware.use Middleware::CreationsMonitor, client @rails_logger.info "[Chillout] creation monitor enabled" client.start_worker @rails_logger.info "[Chillout] worker started" end def options Hash[options_list].merge(:logger => @rails_logger) end def options_list existing_option_keys.map{|key| [key, @chillout_config[key]]} end def existing_option_keys [:port, :hostname, :ssl].select{|key| @chillout_config.has_key?(key)} end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
chillout-0.5.3 | lib/chillout/railtie.rb |
chillout-0.5.2 | lib/chillout/railtie.rb |