Sha256: 015511091f0394fef18208b71be834451ed484a18e53ca083bb8ad66051a9e7b

Contents?: true

Size: 1.35 KB

Versions: 5

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true

require "stenotype/frameworks/rails/action_controller"
require "stenotype/frameworks/rails/active_job"

module Stenotype
  #
  # A Railtie allowing to extend Rails component with
  #   Stenotype extensions for emitting event in various Rails components.
  #
  class Railtie < ::Rails::Railtie
    Stenotype.configure do |config|
      config.rails do |rails_config|
        rails_config.enable_action_controller_ext = true
        rails_config.enable_active_job_ext = true
      end
    end

    config.stenotype = Stenotype.config

    config.after_initialize { config.stenotype.targets.each(&:auto_initialize!) } if config.stenotype.rails.auto_adapter_initialization

    if config.stenotype.rails.enable_action_controller_ext
      ActiveSupport.on_load(:action_controller) do
        Stenotype::ContextHandlers.register Stenotype::ContextHandlers::Rails::Controller
        include Stenotype::Frameworks::Rails::ActionControllerExtension
      end
    end

    # @todo: consider using `::ActiveJob::Base.around_perform`
    #        or `::ActiveJob::Base.around_enqueue`
    if config.stenotype.rails.enable_active_job_ext
      ActiveSupport.on_load(:active_job) do
        Stenotype::ContextHandlers.register Stenotype::ContextHandlers::Rails::ActiveJob
        extend Stenotype::Frameworks::Rails::ActiveJobExtension
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
stenotype-0.1.12 lib/stenotype/railtie.rb
stenotype-0.1.10 lib/stenotype/railtie.rb
stenotype-0.1.9 lib/stenotype/railtie.rb
stenotype-0.1.8 lib/stenotype/railtie.rb
stenotype-0.1.7 lib/stenotype/railtie.rb