Sha256: 74f4a3bc3bd86ebf8cffa45f1ab3e75640748978ce66e26048dfa0327454eb6b

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

module Bemer
  class Railtie < ::Rails::Railtie
    config.eager_load_namespaces << Bemer if config.respond_to?(:eager_load_namespaces)

    config.after_initialize do
      ActionController::Base.prepend_view_path([Bemer.path, *Bemer.paths])
      ActionMailer::Base.prepend_view_path([Bemer.path, *Bemer.paths])
    end

    initializer 'bemer.helpers' do
      ActiveSupport.on_load(:action_view) { include Bemer::Helpers }
    end

    initializer_name =
      case ::Rails::VERSION::MAJOR
      when 5    then :append_assets_path
      when 3..4 then :load_config_initializers
      end

    initializer 'bemer.prepend_asset_paths', group: :all, after: initializer_name do |app|
      next unless defined?(::Sprockets) && Bemer.prepend_asset_paths?

      app.config.assets.paths.unshift(Bemer.path.to_s, *Bemer.asset_paths)
    end

    initializer 'bemer.assets_precompile', group: :all, after: :load_config_initializers do |app|
      next if ::Rails::VERSION::MAJOR > 3 || !defined?(::Sprockets)

      asset_matcher = Bemer::AssetMatcher.new(app.config.assets.precompile.shift)

      app.config.assets.precompile.unshift(asset_matcher)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bemer-0.1.0 lib/bemer/railtie.rb