Class: Rails::Engine::Configuration

Inherits:
Railtie::Configuration show all
Defined in:
lib/rails/engine/configuration.rb

Direct Known Subclasses

Application::Configuration

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Railtie::Configuration

#after_initialize, #app_middleware, #before_configuration, #before_eager_load, #before_initialize, #generators, #respond_to?, #to_prepare, #to_prepare_blocks

Constructor Details

#initialize(root = nil) ⇒ Configuration

Returns a new instance of Configuration.



9
10
11
12
# File 'lib/rails/engine/configuration.rb', line 9

def initialize(root=nil)
  super()
  @root = root
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Rails::Railtie::Configuration

Instance Attribute Details

#autoload_once_pathsObject



44
45
46
# File 'lib/rails/engine/configuration.rb', line 44

def autoload_once_paths
  @autoload_once_paths ||= paths.autoload_once
end

#autoload_pathsObject



48
49
50
# File 'lib/rails/engine/configuration.rb', line 48

def autoload_paths
  @autoload_paths ||= paths.autoload_paths
end

#eager_load_pathsObject



40
41
42
# File 'lib/rails/engine/configuration.rb', line 40

def eager_load_paths
  @eager_load_paths ||= paths.eager_load
end

#rootObject

Returns the value of attribute root.



6
7
8
# File 'lib/rails/engine/configuration.rb', line 6

def root
  @root
end

Instance Method Details

#gem(name, options = {}) ⇒ Object

Rails 3, by default, uses bundler, which shims the Kernel#gem method so that it should behave correctly for this deprecation.



64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/rails/engine/configuration.rb', line 64

def gem(name, options = {})
  super name, options[:version] || ">= 0"
  require options[:lib] || name
rescue Gem::LoadError
  msg = "config.gem is deprecated, and you tried to activate the '#{name}' gem (#{options.inspect}) using it.\n"

  if File.exist?("#{Rails.root}/Gemfile")
    msg << "Please add '#{name}' to your Gemfile."
  else
    msg << "Please update your application to use bundler."
  end
  ActiveSupport::Deprecation.warn(msg, caller)
  exit
end

#load_pathsObject



52
53
54
55
# File 'lib/rails/engine/configuration.rb', line 52

def load_paths
  ActiveSupport::Deprecation.warn "config.load_paths is deprecated. Please use config.autoload_paths instead."
  autoload_paths
end

#load_paths=(paths) ⇒ Object



57
58
59
60
# File 'lib/rails/engine/configuration.rb', line 57

def load_paths=(paths)
  ActiveSupport::Deprecation.warn "config.load_paths= is deprecated. Please use config.autoload_paths instead."
  self.autoload_paths = paths
end

#pathsObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/rails/engine/configuration.rb', line 14

def paths
  @paths ||= begin
    paths = Rails::Paths::Root.new(@root)
    paths.app                 "app",                 :eager_load => true, :glob => "*"
    paths.app.controllers     "app/controllers",     :eager_load => true
    paths.app.helpers         "app/helpers",         :eager_load => true
    paths.app.models          "app/models",          :eager_load => true
    paths.app.mailers         "app/mailers",         :eager_load => true
    paths.app.views           "app/views"
    paths.lib                 "lib",                 :load_path => true
    paths.lib.tasks           "lib/tasks",           :glob => "**/*.rake"
    paths.config              "config"
    paths.config.initializers "config/initializers", :glob => "**/*.rb"
    paths.config.locales      "config/locales",      :glob => "*.{rb,yml}"
    paths.config.routes       "config/routes.rb"
    paths.public              "public"
    paths.public.javascripts  "public/javascripts"
    paths.public.stylesheets  "public/stylesheets"
    paths
  end
end