diff options
author | Piotr Sarnacki <drogus@gmail.com> | 2010-12-08 23:15:13 +0100 |
---|---|---|
committer | Piotr Sarnacki <drogus@gmail.com> | 2010-12-09 01:59:54 +0100 |
commit | 051127d4d38329238bb0b3587ef128f131174786 (patch) | |
tree | 71c0ff67fd88bd4c5a475e3942586a08387a89a0 /railties/lib | |
parent | 5df72a238e9fcb18daf6ab6e6dc9051c9106d7bb (diff) | |
download | rails-051127d4d38329238bb0b3587ef128f131174786.tar.gz rails-051127d4d38329238bb0b3587ef128f131174786.tar.bz2 rails-051127d4d38329238bb0b3587ef128f131174786.zip |
Rails::Engine.find(path) - method to find engine by path
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/application/railties.rb | 8 | ||||
-rw-r--r-- | railties/lib/rails/engine.rb | 5 | ||||
-rw-r--r-- | railties/lib/rails/engine/railties.rb | 10 |
3 files changed, 15 insertions, 8 deletions
diff --git a/railties/lib/rails/application/railties.rb b/railties/lib/rails/application/railties.rb index c1d2de571f..4fc5e92837 100644 --- a/railties/lib/rails/application/railties.rb +++ b/railties/lib/rails/application/railties.rb @@ -8,14 +8,6 @@ module Rails @all.each(&block) if block @all end - - def railties - @railties ||= ::Rails::Railtie.subclasses.map(&:instance) - end - - def engines - @engines ||= ::Rails::Engine.subclasses.map(&:instance) - end end end end diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index 85fa4424c4..b188fdfca1 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -371,6 +371,11 @@ module Rails end end end + + # Finds engine with given path + def find(path) + Rails::Engine::Railties.engines.find { |r| File.expand_path(r.root.to_s) == File.expand_path(path.to_s) } + end end delegate :middleware, :root, :paths, :to => :config diff --git a/railties/lib/rails/engine/railties.rb b/railties/lib/rails/engine/railties.rb index e91bdbf1e5..d5ecd2e48d 100644 --- a/railties/lib/rails/engine/railties.rb +++ b/railties/lib/rails/engine/railties.rb @@ -18,6 +18,16 @@ module Rails Plugin.all(plugin_names, @config.paths["vendor/plugins"].existent) end end + + def self.railties + @railties ||= ::Rails::Railtie.subclasses.map(&:instance) + end + + def self.engines + @engines ||= ::Rails::Engine.subclasses.map(&:instance) + end + + delegate :railties, :engines, :to => "self.class" end end end |