Sha256: e0151d2fd64dd08ee8d9cd6e1a0012c178f34cde59b85892dc48df1274490fbc

Contents?: true

Size: 932 Bytes

Versions: 2

Compression:

Stored size: 932 Bytes

Contents

require 'active_support/concern'

module Trailblazer
  class Railtie < ::Rails::Railtie
    module ExtendApplicationController
      extend ActiveSupport::Concern

      included do
        initializer "trailblazer.application_controller", before: "finisher_hook" do
          reloader_class.to_prepare do
            ActiveSupport.on_load(:action_controller) do |app|
              Trailblazer::Railtie.extend_application_controller!(app)
            end
          end
        end

        def extend_application_controller!(app)
          controllers = Array(::Rails.application.config.trailblazer.application_controller).map { |x| x.to_s }
          if controllers.include? app.to_s
            app.send :include, Trailblazer::Rails::Controller
            app.send :include, Trailblazer::Rails::Controller::Cell if defined?(::Cell)
          end
          app
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
trailblazer-rails-2.1.4 lib/trailblazer/rails/railtie/extend_application_controller.rb
trailblazer-rails-2.1.2 lib/trailblazer/rails/railtie/extend_application_controller.rb