Sha256: 4628dd8777e845a1bd46a34218cfda2c5fbbeb75451fc2ccca95f6148be6cbad
Contents?: true
Size: 1.59 KB
Versions: 18
Compression:
Stored size: 1.59 KB
Contents
require 'rails/railtie' require 'messaging/middleware/after_active_record_transaction' require 'messaging/middleware/rails_wrapper' module Messaging module Rails class Railtie < ::Rails::Railtie config.after_initialize do # Add the wrapper before any middlewares that may have been added by the initializer # in the Rails app. Messaging.config.consumer.middlewares.prepend(Middleware::RailsWrapper.new(::Rails.application)) # Run dispatchers after the current transaction has commited Messaging.config.dispatcher.middlewares.prepend(Middleware::AfterActiveRecordTransaction) # Eager load handlers for development mode to define consumers. # This is needed as long as we use old style handlers that uses "listen_on" # When we only use routing we don't need to eager load. # # Uses require_dependency as normal eager_load with Rails breaks code reloading. next unless ::Rails.env.development? Dir.glob("#{::Rails.root}/app/models/*.rb").each { |h| require_dependency h } Dir.glob("#{::Rails.root}/{app,lib}/**/handlers/**/*.rb").each { |h| require_dependency h } end # As the consumer has a reference to the handler we need to clear that after # the class has been unloaded and update the consumer with the reloaded classes. initializer 'messaging.add_reloader' do |app| app.reloader.after_class_unload do Messaging.routes.reload_consumer_routes! end end config.to_prepare do Messaging.routes.finalize_routes end end end end
Version data entries
18 entries across 18 versions & 1 rubygems