Sha256: 51dd6ef61f11c2525a8d06605ba0d23e7cdfee074b9a5fbfe054417f8e3bd5ba

Contents?: true

Size: 1.93 KB

Versions: 11

Compression:

Stored size: 1.93 KB

Contents

module RailsBase
  class Engine < ::Rails::Engine
    isolate_namespace RailsBase

    # config.autoload_paths << File.expand_path("app", __dir__)

    ActiveSupport::Reloader.to_prepare do
      if RailsBase.___execute_initializer___?
        RailsBase.config.admin.convenience_methods

        Dir[RailsBase::Engine.root.join('app','models','**', '*.rb')].each {|f| require f }
        RailsBase::ApplicationRecord.descendants.each do |model|
          model._magically_defined_time_objects
        end
      end
    end

    initializer 'rails_base.config.intantiate' do |_app|
      RailsBase.config if RailsBase.___execute_initializer___?
    end

    initializer 'rails_base.config.remove_write_acess', after: 'after_initialize' do |app|
      RailsBase::Configuration::Base._unset_allow_write! if RailsBase.___execute_initializer___?
    end

    initializer 'rails_base.magic_convenience_methods.model', before: 'after_initialize' do |app|
      if RailsBase.___execute_initializer___?
        ActiveRecord::Base.retrieve_connection

        # explicitly load engine routes
        RailsBase::ApplicationRecord.descendants.each do |model|
          model._magically_defined_time_objects
        end
      end
    end

    initializer 'rails_base.switch_user.remove_routes', after: 'add_routing_paths' do |app|
      app.routes_reloader.paths.delete_if{ |path| path.include?('switch_user') }
    end

    initializer 'rails_base.append_engine_migrations' do |app|
      unless app.root.to_s.match root.to_s
        config.paths["db/migrate"].expanded.each do |expanded_path|
          app.config.paths["db/migrate"] << expanded_path
        end
      end
    end

    initializer 'rails_base.switch_user.view' do
      config.to_prepare do
        ActiveSupport.on_load(:action_view) do
          require RailsBase::Engine.root.join('lib', 'rails_base', 'switch_user_helper.rb')

          include RailsBase::SwitchUserHelper
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rails_base-0.82.0 lib/rails_base/engine.rb
rails_base-0.81.1 lib/rails_base/engine.rb
rails_base-0.81.0 lib/rails_base/engine.rb
rails_base-0.80.0 lib/rails_base/engine.rb
rails_base-0.75.6 lib/rails_base/engine.rb
rails_base-0.75.5 lib/rails_base/engine.rb
rails_base-0.75.4 lib/rails_base/engine.rb
rails_base-0.75.3 lib/rails_base/engine.rb
rails_base-0.75.2 lib/rails_base/engine.rb
rails_base-0.75.1 lib/rails_base/engine.rb
rails_base-0.75.0 lib/rails_base/engine.rb