Sha256: c59573e04e8ffbb1a9c22ea05305c4e4ef7c59498b99e202225a7554acb56f86

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 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

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chanko-2.0.3 lib/chanko/railtie.rb