Sha256: 0dc904167f9541947b2ece6dbbac6969b85c4042cb50ae33dc1ddab1a521c541

Contents?: true

Size: 921 Bytes

Versions: 1

Compression:

Stored size: 921 Bytes

Contents

require "active_support/concern"

module Trailblazer::V2_1
  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::V2_1::Railtie.extend_application_controller!(app)
            end
          end
        end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
trailblazer-future-2.1.0.rc1 lib/trailblazer/v2_1/rails/railtie/extend_application_controller.rb