Sha256: 2935d77cb3d442c184893eb9114953afa1ebfabe2eb929e280c542a30d592852

Contents?: true

Size: 1.05 KB

Versions: 7

Compression:

Stored size: 1.05 KB

Contents

module Chanko
  class Railtie < Rails::Railtie
    initializer "chanko" do |app|
      ActiveSupport.on_load :action_view do
        ::ActionView::Base.send(:include, Helper, Invoker, UnitProxyProvider)
      end
      ActiveSupport.on_load :action_controller do
        ::ActionController::Base.send(:include, Controller, Invoker, UnitProxyProvider)
      end
      ActiveSupport.on_load :active_record do
        ::ActiveRecord::Base.send(:include, UnitProxyProvider)
        ::ActiveRecord::Relation.send(:include, UnitProxyProvider)
        ::ActiveRecord::Associations::CollectionAssociation.send(:include, UnitProxyProvider)
      end
    end

    initializer("chanko.prevent_units_directory_from_eager_loading", before: :set_autoload_paths) do |app|
      if Chanko::Config.eager_load
        Rails.configuration.eager_load_paths.delete(Rails.root.join(Chanko::Config.units_directory_path).to_s)
      end
    end

    initializer("chanko.eager_load_units") do |app|
      if Chanko::Config.eager_load
        Chanko::Loader.eager_load_units!
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
chanko-2.1.1 lib/chanko/railtie.rb
chanko-2.1.0 lib/chanko/railtie.rb
chanko-2.0.8 lib/chanko/railtie.rb
chanko-2.0.7 lib/chanko/railtie.rb
chanko-2.0.6 lib/chanko/railtie.rb
chanko-2.0.5 lib/chanko/railtie.rb
chanko-2.0.4 lib/chanko/railtie.rb