diff options
author | Piotr Sarnacki <drogus@gmail.com> | 2010-07-19 17:53:14 +0200 |
---|---|---|
committer | Piotr Sarnacki <drogus@gmail.com> | 2010-09-03 22:59:05 +0200 |
commit | 32a5b49911b88e8e410583d382e8253004abce50 (patch) | |
tree | 292bf3c88524241e8740b34a937937b08b3b00b0 /railties/lib/rails/railtie | |
parent | 939d4255e690bd0406179cad00836975273fd49e (diff) | |
download | rails-32a5b49911b88e8e410583d382e8253004abce50.tar.gz rails-32a5b49911b88e8e410583d382e8253004abce50.tar.bz2 rails-32a5b49911b88e8e410583d382e8253004abce50.zip |
Move singleton pattern to Railtie and remove Engine::Configurable and Application::Configurable in favor of unified Railtie::Configurable
Diffstat (limited to 'railties/lib/rails/railtie')
-rw-r--r-- | railties/lib/rails/railtie/configurable.rb | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/railties/lib/rails/railtie/configurable.rb b/railties/lib/rails/railtie/configurable.rb index a2eb938c5a..b6d4ed2312 100644 --- a/railties/lib/rails/railtie/configurable.rb +++ b/railties/lib/rails/railtie/configurable.rb @@ -6,17 +6,29 @@ module Rails end module ClassMethods - def config - @config ||= Railtie::Configuration.new - end + delegate :config, :to => :instance def inherited(base) - raise "You cannot inherit from a Rails::Railtie child" + raise "You cannot inherit from a #{self.superclass.name} child" end - end - def config - self.class.config + def instance + @instance ||= new + end + + def respond_to?(*args) + super || instance.respond_to?(*args) + end + + def configure(&block) + class_eval(&block) + end + + protected + + def method_missing(*args, &block) + instance.send(*args, &block) + end end end end |