diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-05-07 10:29:22 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-05-07 10:29:22 -0500 |
commit | 2854535b02bcee3668bda02c76c3105fc24730d3 (patch) | |
tree | b78660942bdc6f532a1109da57ee40d7d31cf603 /activesupport/lib | |
parent | 783deae99a4850f597135146b19e7ee4622da94e (diff) | |
download | rails-2854535b02bcee3668bda02c76c3105fc24730d3.tar.gz rails-2854535b02bcee3668bda02c76c3105fc24730d3.tar.bz2 rails-2854535b02bcee3668bda02c76c3105fc24730d3.zip |
Make module dependency DSL opt in
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support.rb | 1 | ||||
-rw-r--r-- | activesupport/lib/active_support/core_ext/module.rb | 1 | ||||
-rw-r--r-- | activesupport/lib/active_support/core_ext/module/setup.rb | 26 | ||||
-rw-r--r-- | activesupport/lib/active_support/dependency_module.rb | 24 |
4 files changed, 25 insertions, 27 deletions
diff --git a/activesupport/lib/active_support.rb b/activesupport/lib/active_support.rb index 0879535487..dab017770d 100644 --- a/activesupport/lib/active_support.rb +++ b/activesupport/lib/active_support.rb @@ -34,6 +34,7 @@ module ActiveSupport autoload :Callbacks, 'active_support/callbacks' autoload :NewCallbacks, 'active_support/new_callbacks' autoload :ConcurrentHash, 'active_support/concurrent_hash' + autoload :DependencyModule, 'active_support/dependency_module' autoload :Deprecation, 'active_support/deprecation' autoload :Gzip, 'active_support/gzip' autoload :Inflector, 'active_support/inflector' diff --git a/activesupport/lib/active_support/core_ext/module.rb b/activesupport/lib/active_support/core_ext/module.rb index fee91534e7..215c47b114 100644 --- a/activesupport/lib/active_support/core_ext/module.rb +++ b/activesupport/lib/active_support/core_ext/module.rb @@ -9,4 +9,3 @@ require 'active_support/core_ext/module/delegation' require 'active_support/core_ext/module/loading' require 'active_support/core_ext/module/model_naming' require 'active_support/core_ext/module/synchronization' -require 'active_support/core_ext/module/setup' diff --git a/activesupport/lib/active_support/core_ext/module/setup.rb b/activesupport/lib/active_support/core_ext/module/setup.rb deleted file mode 100644 index e6dfd0cf56..0000000000 --- a/activesupport/lib/active_support/core_ext/module/setup.rb +++ /dev/null @@ -1,26 +0,0 @@ -class Module - attr_accessor :_setup_block - attr_accessor :_dependencies - - def setup(&blk) - @_setup_block = blk - end - - def use(mod) - return if self < mod - - (mod._dependencies || []).each do |dep| - use dep - end - # raise "Circular dependencies" if self < mod - include mod - extend mod.const_get("ClassMethods") if mod.const_defined?("ClassMethods") - class_eval(&mod._setup_block) if mod._setup_block - end - - def depends_on(mod) - return if self < mod - @_dependencies ||= [] - @_dependencies << mod - end -end
\ No newline at end of file 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 |