aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/dependency_module.rb
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2009-05-07 10:29:22 -0500
committerJoshua Peek <josh@joshpeek.com>2009-05-07 10:29:22 -0500
commit2854535b02bcee3668bda02c76c3105fc24730d3 (patch)
treeb78660942bdc6f532a1109da57ee40d7d31cf603 /activesupport/lib/active_support/dependency_module.rb
parent783deae99a4850f597135146b19e7ee4622da94e (diff)
downloadrails-2854535b02bcee3668bda02c76c3105fc24730d3.tar.gz
rails-2854535b02bcee3668bda02c76c3105fc24730d3.tar.bz2
rails-2854535b02bcee3668bda02c76c3105fc24730d3.zip
Make module dependency DSL opt in
Diffstat (limited to 'activesupport/lib/active_support/dependency_module.rb')
-rw-r--r--activesupport/lib/active_support/dependency_module.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/dependency_module.rb b/activesupport/lib/active_support/dependency_module.rb
new file mode 100644
index 0000000000..0e1cc67b53
--- /dev/null
+++ b/activesupport/lib/active_support/dependency_module.rb
@@ -0,0 +1,24 @@
+module ActiveSupport
+ module DependencyModule
+ def setup(&blk)
+ @_setup_block = blk
+ end
+
+ def append_features(base)
+ return if base < self
+ (@_dependencies ||= []).each { |dep| base.send(:include, dep) }
+ super
+ end
+
+ def included(base)
+ base.extend const_get("ClassMethods") if const_defined?("ClassMethods")
+ base.class_eval(&@_setup_block) if instance_variable_defined?("@_setup_block")
+ end
+
+ def depends_on(mod)
+ return if self < mod
+ @_dependencies ||= []
+ @_dependencies << mod
+ end
+ end
+end