1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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

This commit is contained in:
Joshua Peek 2009-05-29 17:03:23 -05:00
parent c7c35be8fe
commit 669fd84910
21 changed files with 31 additions and 31 deletions

View file

@ -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 file

@ -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 file

@ -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 file

@ -2,7 +2,7 @@ module AbstractController
module Layouts
extend ActiveSupport::Concern
depends_on Renderer
include Renderer
included do
extlib_inheritable_accessor :_layout_conditions

View file

@ -4,7 +4,7 @@ module AbstractController
module Renderer
extend ActiveSupport::Concern
depends_on AbstractController::Logger
include AbstractController::Logger
included do
attr_internal :formats

View file

@ -29,7 +29,7 @@ module ActionController #:nodoc:
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 file

@ -4,13 +4,11 @@ module ActionController
# 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 file

@ -7,7 +7,7 @@ module ActionController #:nodoc:
# 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 file

@ -6,7 +6,7 @@ module ActionController #:nodoc:
# 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 file

@ -4,7 +4,7 @@ module ActionController #: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 file

@ -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 file

@ -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 file

@ -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 file

@ -39,7 +39,7 @@ module ActionController
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 @@ module ActionController
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 file

@ -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 file

@ -2,7 +2,7 @@ module ActionController
module Session
extend ActiveSupport::Concern
depends_on RackConvenience
include RackConvenience
def session
@_request.session

View file

@ -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 file

@ -2,7 +2,7 @@ module ActionController
module UrlFor
extend ActiveSupport::Concern
depends_on RackConvenience
include RackConvenience
def process_action(*)
initialize_current_url

View file

@ -102,8 +102,8 @@ module ActiveRecord
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 file

@ -19,5 +19,7 @@ module ActiveSupport
super
end
end
alias_method :include, :depends_on
end
end

View file

@ -34,7 +34,7 @@ class ConcernTest < Test::Unit::TestCase
module Bar
extend ActiveSupport::Concern
depends_on Baz
include Baz
def bar
"bar"
@ -48,7 +48,7 @@ class ConcernTest < Test::Unit::TestCase
module Foo
extend ActiveSupport::Concern
depends_on Bar, Baz
include Bar, Baz
end
def setup
@ -90,7 +90,7 @@ class ConcernTest < Test::Unit::TestCase
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