Skip to content
Browse files

AS::Concern redefines "include" to lazy include modules as dependencies

  • Loading branch information...
1 parent c7c35be commit 669fd84910586d4c791b6f5bf4320f68ac7845aa @josh josh committed May 29, 2009
View
2 actionpack/lib/action_controller/abstract/benchmarker.rb
@@ -2,7 +2,7 @@ module AbstractController
module Benchmarker
extend ActiveSupport::Concern
- depends_on Logger
+ include Logger
module ClassMethods
def benchmark(title, log_level = ::Logger::DEBUG, use_silence = true)
View
2 actionpack/lib/action_controller/abstract/callbacks.rb
@@ -2,7 +2,7 @@ module AbstractController
module Callbacks
extend ActiveSupport::Concern
- depends_on ActiveSupport::NewCallbacks
+ include ActiveSupport::NewCallbacks
included do
define_callbacks :process_action, "response_body"
View
2 actionpack/lib/action_controller/abstract/helpers.rb
@@ -2,7 +2,7 @@ module AbstractController
module Helpers
extend ActiveSupport::Concern
- depends_on Renderer
+ include Renderer
included do
extlib_inheritable_accessor :master_helper_module
View
2 actionpack/lib/action_controller/abstract/layouts.rb
@@ -2,7 +2,7 @@ module AbstractController
module Layouts
extend ActiveSupport::Concern
- depends_on Renderer
+ include Renderer
included do
extlib_inheritable_accessor :_layout_conditions
View
2 actionpack/lib/action_controller/abstract/renderer.rb
@@ -4,7 +4,7 @@ module AbstractController
module Renderer
extend ActiveSupport::Concern
- depends_on AbstractController::Logger
+ include AbstractController::Logger
included do
attr_internal :formats
View
2 actionpack/lib/action_controller/base/chained/flash.rb
@@ -29,7 +29,7 @@ module Flash
extend ActiveSupport::Concern
# TODO : Remove the defined? check when new base is the main base
- depends_on Session if defined?(ActionController::Http)
+ include Session if defined?(ActionController::Http)
included do
# TODO : Remove the defined? check when new base is the main base
View
6 actionpack/lib/action_controller/base/filter_parameter_logging.rb
@@ -4,13 +4,11 @@ module FilterParameterLogging
# TODO : Remove the defined? check when new base is the main base
if defined?(ActionController::Http)
- depends_on AbstractController::Logger
+ include AbstractController::Logger
end
included do
- if defined?(ActionController::Http)
- include InstanceMethodsForNewBase
- end
+ include InstanceMethodsForNewBase
end
module ClassMethods
View
2 actionpack/lib/action_controller/base/request_forgery_protection.rb
@@ -7,7 +7,7 @@ module RequestForgeryProtection
# TODO : Remove the defined? check when new base is the main base
if defined?(ActionController::Http)
- depends_on AbstractController::Helpers, Session
+ include AbstractController::Helpers, Session
end
included do
View
2 actionpack/lib/action_controller/base/streaming.rb
@@ -6,7 +6,7 @@ module Streaming
# TODO : Remove the defined? check when new base is the main base
if defined?(ActionController::Http)
- depends_on ActionController::Renderer
+ include ActionController::Renderer
end
DEFAULT_SEND_FILE_OPTIONS = {
View
2 actionpack/lib/action_controller/base/verification.rb
@@ -4,7 +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, Session, Flash, Renderer
+ include AbstractController::Callbacks, Session, Flash, Renderer
end
# This module provides a class-level method for specifying that certain
View
2 actionpack/lib/action_controller/new_base/conditional_get.rb
@@ -2,7 +2,7 @@ module ActionController
module ConditionalGet
extend ActiveSupport::Concern
- depends_on RackConvenience
+ include RackConvenience
# Sets the etag, last_modified, or both on the response and renders a
# "304 Not Modified" response if the request is already fresh.
View
2 actionpack/lib/action_controller/new_base/helpers.rb
@@ -6,7 +6,7 @@ module ActionController
module Helpers
extend ActiveSupport::Concern
- depends_on AbstractController::Helpers
+ include AbstractController::Helpers
included do
# Set the default directory for helpers
View
4 actionpack/lib/action_controller/new_base/layouts.rb
@@ -2,8 +2,8 @@ module ActionController
module Layouts
extend ActiveSupport::Concern
- depends_on ActionController::Renderer
- depends_on AbstractController::Layouts
+ include ActionController::Renderer
+ include AbstractController::Layouts
module ClassMethods
def _implied_layout_name
View
10 actionpack/lib/action_controller/new_base/render_options.rb
@@ -39,7 +39,7 @@ def render_to_body(options)
module RenderOption #:nodoc:
def self.extended(base)
base.extend ActiveSupport::Concern
- base.depends_on ::ActionController::RenderOptions
+ base.send :include, ::ActionController::RenderOptions
def base.register_renderer(name)
included { _add_render_option(name) }
@@ -94,10 +94,10 @@ def _render_update(proc, options)
module All
extend ActiveSupport::Concern
- depends_on ActionController::Renderers::Json
- depends_on ActionController::Renderers::Js
- depends_on ActionController::Renderers::Xml
- depends_on ActionController::Renderers::RJS
+ include ActionController::Renderers::Json
+ include ActionController::Renderers::Js
+ include ActionController::Renderers::Xml
+ include ActionController::Renderers::RJS
end
end
end
View
2 actionpack/lib/action_controller/new_base/renderer.rb
@@ -2,7 +2,7 @@ module ActionController
module Renderer
extend ActiveSupport::Concern
- depends_on AbstractController::Renderer
+ include AbstractController::Renderer
def process_action(*)
self.formats = request.formats.map {|x| x.to_sym}
View
2 actionpack/lib/action_controller/new_base/session.rb
@@ -2,7 +2,7 @@ module ActionController
module Session
extend ActiveSupport::Concern
- depends_on RackConvenience
+ include RackConvenience
def session
@_request.session
View
2 actionpack/lib/action_controller/new_base/testing.rb
@@ -2,7 +2,7 @@ module ActionController
module Testing
extend ActiveSupport::Concern
- depends_on RackConvenience
+ include RackConvenience
# OMG MEGA HAX
def process_with_new_base_test(request, response)
View
2 actionpack/lib/action_controller/new_base/url_for.rb
@@ -2,7 +2,7 @@ module ActionController
module UrlFor
extend ActiveSupport::Concern
- depends_on RackConvenience
+ include RackConvenience
def process_action(*)
initialize_current_url
View
4 activerecord/lib/active_record/validations.rb
@@ -102,8 +102,8 @@ def generate_message(attribute, message = :invalid, options = {})
module Validations
extend ActiveSupport::Concern
- depends_on ActiveSupport::Callbacks
- depends_on ActiveModel::Validations
+ include ActiveSupport::Callbacks
+ include ActiveModel::Validations
included do
alias_method_chain :save, :validation
View
2 activesupport/lib/active_support/concern.rb
@@ -19,5 +19,7 @@ def included(base = nil, &block)
super
end
end
+
+ alias_method :include, :depends_on
end
end
View
6 activesupport/test/concern_test.rb
@@ -34,7 +34,7 @@ def baz
module Bar
extend ActiveSupport::Concern
- depends_on Baz
+ include Baz
def bar
"bar"
@@ -48,7 +48,7 @@ def baz
module Foo
extend ActiveSupport::Concern
- depends_on Bar, Baz
+ include Bar, Baz
end
def setup
@@ -90,7 +90,7 @@ def test_modules_dependencies_are_met
assert @klass.included_modules.include?(ConcernTest::Bar)
end
- def test_depends_on_with_multiple_modules
+ def test_dependencies_with_multiple_modules
@klass.send(:include, Foo)
assert_equal [ConcernTest::Foo, ConcernTest::Bar, ConcernTest::Baz::InstanceMethods, ConcernTest::Baz], @klass.included_modules[0..3]
end

0 comments on commit 669fd84

Please sign in to comment.
Something went wrong with that request. Please try again.