Browse files

Allow Module#depends_on to accept multiple modules

  • Loading branch information...
1 parent e21d161 commit 5a036457620b7fb22027dc4f0c399871db6ed0c3 @lifo lifo committed May 21, 2009
View
5 actionpack/lib/action_controller/base/verification.rb
@@ -4,10 +4,7 @@ module Verification #:nodoc:
# TODO : Remove the defined? check when new base is the main base
if defined?(ActionController::Http)
- depends_on AbstractController::Callbacks
- depends_on Session
- depends_on Flash
- depends_on Renderer
+ depends_on AbstractController::Callbacks, Session, Flash, Renderer
end
# This module provides a class-level method for specifying that certain
View
10 activesupport/lib/active_support/dependency_module.rb
@@ -16,10 +16,12 @@ def included(base = nil, &block)
end
end
- def depends_on(mod)
- return if self < mod
- @_dependencies ||= []
- @_dependencies << mod
+ def depends_on(*mods)
+ mods.each do |mod|
+ next if self < mod
+ @_dependencies ||= []
+ @_dependencies << mod
+ end
end
end
end
View
11 activesupport/test/dependency_module_test.rb
@@ -42,6 +42,12 @@ def baz
end
end
+ module Foo
+ extend ActiveSupport::DependencyModule
+
+ depends_on Bar, Baz
+ end
+
def setup
@klass = Class.new
end
@@ -74,4 +80,9 @@ def test_modules_dependencies_are_met
assert_equal "baz", @klass.baz
assert_equal [DependencyModuleTest::Bar, DependencyModuleTest::Baz], @klass.included_modules[0..1]
end
+
+ def test_depends_on_with_multiple_modules
+ @klass.send(:include, Foo)
+ assert_equal [DependencyModuleTest::Foo, DependencyModuleTest::Bar, DependencyModuleTest::Baz], @klass.included_modules[0..2]
+ end
end

0 comments on commit 5a03645

Please sign in to comment.