Sha256: adb69b65c7ebc12d4aa47c554d5b6879942a6fb023fb6445c623958e0c1516a3

Contents?: true

Size: 1.16 KB

Versions: 5

Compression:

Stored size: 1.16 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
    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.19 lib/stenotype/railtie.rb
stenotype-0.1.17 lib/stenotype/railtie.rb
stenotype-0.1.16 lib/stenotype/railtie.rb
stenotype-0.1.15 lib/stenotype/railtie.rb
stenotype-0.1.13 lib/stenotype/railtie.rb