Sha256: ffc28a4819a0b09fd0722afe149409f07c6177ea96af4029eb07a0237890a74d

Contents?: true

Size: 839 Bytes

Versions: 4

Compression:

Stored size: 839 Bytes

Contents

# frozen_string_literal: true

module Msgr
  class Railtie < ::Rails::Railtie
    config.msgr = ActiveSupport::OrderedOptions.new

    initializer 'msgr.logger' do |app|
      app.config.msgr.logger ||= Rails.logger
    end

    initializer 'msgr.start' do
      config.after_initialize do |app|
        Msgr.logger = app.config.msgr.logger
        self.class.load(app.config_for(:rabbitmq).symbolize_keys)
      end
    end

    rake_tasks do
      load File.expand_path('tasks/msgr/drain.rake', __dir__)
    end

    class << self
      def load(config)
        # Set defaults
        config.reverse_merge!(
          checkcredentials: true,
          routing_file: Rails.root.join('config/msgr.rb').to_s,
        )

        Msgr.config = config
        Msgr.client.connect if config.fetch(:checkcredentials)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
msgr-1.6.1 lib/msgr/railtie.rb
msgr-1.6.0 lib/msgr/railtie.rb
msgr-1.5.0 lib/msgr/railtie.rb
msgr-1.4.0 lib/msgr/railtie.rb