Sha256: 08be774109e0fb9c5e1d1157bce02b4f60581dd74942195a838a8d2cd17d05ab

Contents?: true

Size: 1.83 KB

Versions: 5

Compression:

Stored size: 1.83 KB

Contents



# Constants

module Eitil
  
  Root   = Gem.loaded_specs['eitil'].full_gem_path
  Layers = %w( eitil_core eitil_support eitil_wrapper eitil_store eitil_integrate )
  ApplicationRecordModules = []

end



# Configuration

module Eitil 
  class Railtie < ::Rails::Railtie   
    
    # The following configuration has its own special place in the boot sequence:
    # on the one hand, it should run before the initialization of Eitil (gem), but
    # read config assigned by the main app – which is only loaded AFTER all gems have
    # been initialized.

    # Therefore, we only require the specified file from the main app, after defining
    # the possible configurations for the Eitil railtie. This way we escape the boot
    # sequence's dedault order.

    config.before_initialize do |eitil|

      Eitil.mattr_accessor :controller_ivars, 
                           :skip_default_scopes_for_models,
                           :skip_callback_helper_methods_for_models

      Eitil.controller_ivars ||= []
      Eitil.skip_default_scopes_for_models ||= []
      Eitil.skip_callback_helper_methods_for_models ||= []

      def Eitil.set_config(&block)
        yield Eitil
      end

      config_path = Rails.root + 'config/initializers/eitil.rb'
    
      if File.exists? config_path
        puts "Loading Eitil config from #{config_path}..."
        load config_path
      else
        puts "Eitil config not found at #{config_path}, resorting to defaults..."
      end

    end
  end
end



# Loading

module Eitil
  
  class Railtie < ::Rails::Railtie   
    
    Eitil::Layers.each do |layer|

      # Add lib dirs to $LOAD_PATH, making them available in your main app.
      $LOAD_PATH << "#{Eitil::Root}/#{layer}/lib"

      # Load railtie into main app, enabling on the fly inclusion of dispatches.
      require "#{layer}/railtie"
      
    end

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
eitil-1.2.2 lib/eitil/railtie.rb
eitil-1.2.1 lib/eitil/railtie.rb
eitil-1.2.0 lib/eitil/railtie.rb
eitil-1.1.39 lib/eitil/railtie.rb
eitil-1.1.38 lib/eitil/railtie.rb