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_generators, #app_middleware, #before_configuration, #before_eager_load, #before_initialize, #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



50
51
52
# File 'lib/rails/engine/configuration.rb', line 50

def autoload_once_paths
  @autoload_once_paths ||= paths.autoload_once
end

#autoload_pathsObject



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

def autoload_paths
  @autoload_paths ||= paths.autoload_paths
end

#eager_load_pathsObject



46
47
48
# File 'lib/rails/engine/configuration.rb', line 46

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.



70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/rails/engine/configuration.rb', line 70

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

#generatorsObject

:nodoc:



36
37
38
39
40
# File 'lib/rails/engine/configuration.rb', line 36

def generators #:nodoc:
  ActiveSupport::Deprecation.warn "config.generators in Rails::Engine is deprecated. " <<
    "Please use config.app_generators instead."
  super
end

#load_pathsObject



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

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

#load_paths=(paths) ⇒ Object



63
64
65
66
# File 'lib/rails/engine/configuration.rb', line 63

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