aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/engine/configurable.rb
blob: 0af01cace234f0f6f38da37656cfcb1b5905a5eb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
module Rails
  class Engine
    module Configurable
      def self.included(base)
        base.extend ClassMethods
        base.private_class_method :new
      end

      module ClassMethods
        delegate :middleware, :root, :paths, :to => :config
        delegate :call, :to => :instance

        def config
          @config ||= Engine::Configuration.new(find_root_with_flag("lib"))
        end

        def inherited(base)
          raise "You cannot inherit from a Rails::Engine child"
        end

        def instance
          @instance ||= new
        end

        def endpoint(endpoint = nil)
          @endpoint = endpoint if endpoint
          @endpoint
        end
      end

      def config
        self.class.config
      end
    end
  end
end