diff --git a/actionpack/lib/action_controller/abstract/benchmarker.rb b/actionpack/lib/action_controller/abstract/benchmarker.rb index 9be06f48fb..6999329144 100644 --- a/actionpack/lib/action_controller/abstract/benchmarker.rb +++ b/actionpack/lib/action_controller/abstract/benchmarker.rb @@ -1,6 +1,6 @@ module AbstractController module Benchmarker - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern depends_on Logger diff --git a/actionpack/lib/action_controller/abstract/callbacks.rb b/actionpack/lib/action_controller/abstract/callbacks.rb index 4314235ba9..6c67315c58 100644 --- a/actionpack/lib/action_controller/abstract/callbacks.rb +++ b/actionpack/lib/action_controller/abstract/callbacks.rb @@ -1,6 +1,6 @@ module AbstractController module Callbacks - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern depends_on ActiveSupport::NewCallbacks diff --git a/actionpack/lib/action_controller/abstract/helpers.rb b/actionpack/lib/action_controller/abstract/helpers.rb index 7b1b197e1d..43832f1e2d 100644 --- a/actionpack/lib/action_controller/abstract/helpers.rb +++ b/actionpack/lib/action_controller/abstract/helpers.rb @@ -1,6 +1,6 @@ module AbstractController module Helpers - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern depends_on Renderer diff --git a/actionpack/lib/action_controller/abstract/layouts.rb b/actionpack/lib/action_controller/abstract/layouts.rb index dd38485271..b3f21f7b22 100644 --- a/actionpack/lib/action_controller/abstract/layouts.rb +++ b/actionpack/lib/action_controller/abstract/layouts.rb @@ -1,6 +1,6 @@ module AbstractController module Layouts - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern depends_on Renderer diff --git a/actionpack/lib/action_controller/abstract/logger.rb b/actionpack/lib/action_controller/abstract/logger.rb index ce73888763..d6fa843485 100644 --- a/actionpack/lib/action_controller/abstract/logger.rb +++ b/actionpack/lib/action_controller/abstract/logger.rb @@ -3,7 +3,7 @@ require 'active_support/core_ext/logger' module AbstractController module Logger - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern class DelayedLog def initialize(&blk) diff --git a/actionpack/lib/action_controller/abstract/renderer.rb b/actionpack/lib/action_controller/abstract/renderer.rb index 374ceb5b74..cd3e87d861 100644 --- a/actionpack/lib/action_controller/abstract/renderer.rb +++ b/actionpack/lib/action_controller/abstract/renderer.rb @@ -2,7 +2,7 @@ require "action_controller/abstract/logger" module AbstractController module Renderer - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern depends_on AbstractController::Logger diff --git a/actionpack/lib/action_controller/base/chained/flash.rb b/actionpack/lib/action_controller/base/chained/flash.rb index 2d084ba1ab..04d27bf090 100644 --- a/actionpack/lib/action_controller/base/chained/flash.rb +++ b/actionpack/lib/action_controller/base/chained/flash.rb @@ -26,7 +26,7 @@ module ActionController #:nodoc: # # See docs on the FlashHash class for more details about the flash. module Flash - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern # TODO : Remove the defined? check when new base is the main base depends_on Session if defined?(ActionController::Http) diff --git a/actionpack/lib/action_controller/base/filter_parameter_logging.rb b/actionpack/lib/action_controller/base/filter_parameter_logging.rb index f5a678ca03..9df286ee24 100644 --- a/actionpack/lib/action_controller/base/filter_parameter_logging.rb +++ b/actionpack/lib/action_controller/base/filter_parameter_logging.rb @@ -1,6 +1,6 @@ module ActionController module FilterParameterLogging - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern # TODO : Remove the defined? check when new base is the main base if defined?(ActionController::Http) diff --git a/actionpack/lib/action_controller/base/helpers.rb b/actionpack/lib/action_controller/base/helpers.rb index 96fa7896a9..f74158bc13 100644 --- a/actionpack/lib/action_controller/base/helpers.rb +++ b/actionpack/lib/action_controller/base/helpers.rb @@ -3,7 +3,7 @@ require 'active_support/dependencies' # FIXME: helper { ... } is broken on Ruby 1.9 module ActionController #:nodoc: module Helpers #:nodoc: - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern included do # Initialize the base module to aggregate its helpers. diff --git a/actionpack/lib/action_controller/base/request_forgery_protection.rb b/actionpack/lib/action_controller/base/request_forgery_protection.rb index 0a0e20e1f1..368c6e9de8 100644 --- a/actionpack/lib/action_controller/base/request_forgery_protection.rb +++ b/actionpack/lib/action_controller/base/request_forgery_protection.rb @@ -3,7 +3,7 @@ module ActionController #:nodoc: end module RequestForgeryProtection - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern # TODO : Remove the defined? check when new base is the main base if defined?(ActionController::Http) diff --git a/actionpack/lib/action_controller/base/streaming.rb b/actionpack/lib/action_controller/base/streaming.rb index 5872ba99a2..5f56c95483 100644 --- a/actionpack/lib/action_controller/base/streaming.rb +++ b/actionpack/lib/action_controller/base/streaming.rb @@ -2,7 +2,7 @@ module ActionController #:nodoc: # Methods for sending arbitrary data and for streaming files to the browser, # instead of rendering. module Streaming - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern # TODO : Remove the defined? check when new base is the main base if defined?(ActionController::Http) diff --git a/actionpack/lib/action_controller/base/verification.rb b/actionpack/lib/action_controller/base/verification.rb index 3fa5a105b1..31654e36f3 100644 --- a/actionpack/lib/action_controller/base/verification.rb +++ b/actionpack/lib/action_controller/base/verification.rb @@ -1,6 +1,6 @@ module ActionController #:nodoc: module Verification #:nodoc: - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern # TODO : Remove the defined? check when new base is the main base if defined?(ActionController::Http) diff --git a/actionpack/lib/action_controller/caching.rb b/actionpack/lib/action_controller/caching.rb index 2f2eec10f6..38cf1da6a8 100644 --- a/actionpack/lib/action_controller/caching.rb +++ b/actionpack/lib/action_controller/caching.rb @@ -24,7 +24,7 @@ module ActionController #:nodoc: # ActionController::Base.cache_store = :mem_cache_store, "localhost" # ActionController::Base.cache_store = MyOwnStore.new("parameter") module Caching - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern autoload :Actions, 'action_controller/caching/actions' autoload :Fragments, 'action_controller/caching/fragments' diff --git a/actionpack/lib/action_controller/new_base/compatibility.rb b/actionpack/lib/action_controller/new_base/compatibility.rb index 1d0cb601e3..f278c2da14 100644 --- a/actionpack/lib/action_controller/new_base/compatibility.rb +++ b/actionpack/lib/action_controller/new_base/compatibility.rb @@ -1,6 +1,6 @@ module ActionController module Rails2Compatibility - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern class ::ActionController::ActionControllerError < StandardError #:nodoc: end diff --git a/actionpack/lib/action_controller/new_base/conditional_get.rb b/actionpack/lib/action_controller/new_base/conditional_get.rb index 38f3d3cf68..8bd6db500b 100644 --- a/actionpack/lib/action_controller/new_base/conditional_get.rb +++ b/actionpack/lib/action_controller/new_base/conditional_get.rb @@ -1,6 +1,6 @@ module ActionController module ConditionalGet - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern depends_on RackConvenience diff --git a/actionpack/lib/action_controller/new_base/helpers.rb b/actionpack/lib/action_controller/new_base/helpers.rb index 1dece13114..c2ebd343e3 100644 --- a/actionpack/lib/action_controller/new_base/helpers.rb +++ b/actionpack/lib/action_controller/new_base/helpers.rb @@ -4,7 +4,7 @@ require 'active_support/dependencies' module ActionController module Helpers - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern depends_on AbstractController::Helpers diff --git a/actionpack/lib/action_controller/new_base/hide_actions.rb b/actionpack/lib/action_controller/new_base/hide_actions.rb index 10b8b582f5..b45e520bee 100644 --- a/actionpack/lib/action_controller/new_base/hide_actions.rb +++ b/actionpack/lib/action_controller/new_base/hide_actions.rb @@ -1,6 +1,6 @@ module ActionController module HideActions - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern included do extlib_inheritable_accessor :hidden_actions diff --git a/actionpack/lib/action_controller/new_base/layouts.rb b/actionpack/lib/action_controller/new_base/layouts.rb index 9b4057caaa..727358c394 100644 --- a/actionpack/lib/action_controller/new_base/layouts.rb +++ b/actionpack/lib/action_controller/new_base/layouts.rb @@ -1,6 +1,6 @@ module ActionController module Layouts - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern depends_on ActionController::Renderer depends_on AbstractController::Layouts diff --git a/actionpack/lib/action_controller/new_base/rack_convenience.rb b/actionpack/lib/action_controller/new_base/rack_convenience.rb index e465acca6e..5dfa7d12f3 100644 --- a/actionpack/lib/action_controller/new_base/rack_convenience.rb +++ b/actionpack/lib/action_controller/new_base/rack_convenience.rb @@ -1,6 +1,6 @@ module ActionController module RackConvenience - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern included do delegate :headers, :status=, :location=, diff --git a/actionpack/lib/action_controller/new_base/render_options.rb b/actionpack/lib/action_controller/new_base/render_options.rb index f12198a710..04b954134f 100644 --- a/actionpack/lib/action_controller/new_base/render_options.rb +++ b/actionpack/lib/action_controller/new_base/render_options.rb @@ -1,6 +1,6 @@ module ActionController module RenderOptions - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern included do extlib_inheritable_accessor :_renderers @@ -36,14 +36,12 @@ module ActionController end end - module RenderOption - extend ActiveSupport::DependencyModule + module RenderOption #:nodoc: + def self.extended(base) + base.extend ActiveSupport::Concern + base.depends_on ::ActionController::RenderOptions - included do - extend ActiveSupport::DependencyModule - depends_on ::ActionController::RenderOptions - - def self.register_renderer(name) + def base.register_renderer(name) included { _add_render_option(name) } end end @@ -51,7 +49,7 @@ module ActionController module Renderers module Json - include RenderOption + extend RenderOption register_renderer :json def _render_json(json, options) @@ -63,7 +61,7 @@ module ActionController end module Js - include RenderOption + extend RenderOption register_renderer :js def _render_js(js, options) @@ -73,7 +71,7 @@ module ActionController end module Xml - include RenderOption + extend RenderOption register_renderer :xml def _render_xml(xml, options) @@ -82,8 +80,8 @@ module ActionController end end - module Rjs - include RenderOption + module RJS + extend RenderOption register_renderer :update def _render_update(proc, options) @@ -94,14 +92,12 @@ module ActionController end module All - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern - included do - include ::ActionController::Renderers::Json - include ::ActionController::Renderers::Js - include ::ActionController::Renderers::Xml - include ::ActionController::Renderers::Rjs - end + depends_on ActionController::Renderers::Json + depends_on ActionController::Renderers::Js + depends_on ActionController::Renderers::Xml + depends_on ActionController::Renderers::RJS end end end diff --git a/actionpack/lib/action_controller/new_base/renderer.rb b/actionpack/lib/action_controller/new_base/renderer.rb index 737a0d6fcf..e132d4fdbb 100644 --- a/actionpack/lib/action_controller/new_base/renderer.rb +++ b/actionpack/lib/action_controller/new_base/renderer.rb @@ -1,6 +1,6 @@ module ActionController module Renderer - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern depends_on AbstractController::Renderer diff --git a/actionpack/lib/action_controller/new_base/rescuable.rb b/actionpack/lib/action_controller/new_base/rescuable.rb index 4450a1131a..029e643d93 100644 --- a/actionpack/lib/action_controller/new_base/rescuable.rb +++ b/actionpack/lib/action_controller/new_base/rescuable.rb @@ -15,7 +15,7 @@ module ActionController #:nodoc: # behavior is achieved by overriding the rescue_action_in_public # and rescue_action_locally methods. module Rescue - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern included do include ActiveSupport::Rescuable diff --git a/actionpack/lib/action_controller/new_base/session.rb b/actionpack/lib/action_controller/new_base/session.rb index 9ee3e9e136..a585630230 100644 --- a/actionpack/lib/action_controller/new_base/session.rb +++ b/actionpack/lib/action_controller/new_base/session.rb @@ -1,6 +1,6 @@ module ActionController module Session - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern depends_on RackConvenience diff --git a/actionpack/lib/action_controller/new_base/testing.rb b/actionpack/lib/action_controller/new_base/testing.rb index 97aadfe78f..e8d210d149 100644 --- a/actionpack/lib/action_controller/new_base/testing.rb +++ b/actionpack/lib/action_controller/new_base/testing.rb @@ -1,6 +1,6 @@ module ActionController module Testing - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern depends_on RackConvenience diff --git a/actionpack/lib/action_controller/new_base/url_for.rb b/actionpack/lib/action_controller/new_base/url_for.rb index 87bc689134..902cac4d15 100644 --- a/actionpack/lib/action_controller/new_base/url_for.rb +++ b/actionpack/lib/action_controller/new_base/url_for.rb @@ -1,6 +1,6 @@ module ActionController module UrlFor - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern depends_on RackConvenience diff --git a/actionpack/lib/action_controller/testing/integration.rb b/actionpack/lib/action_controller/testing/integration.rb index cc157816e2..af4ccb7837 100644 --- a/actionpack/lib/action_controller/testing/integration.rb +++ b/actionpack/lib/action_controller/testing/integration.rb @@ -301,7 +301,7 @@ module ActionController # A module used to extend ActionController::Base, so that integration tests # can capture the controller used to satisfy a request. module ControllerCapture #:nodoc: - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern included do alias_method_chain :initialize, :capture diff --git a/actionpack/lib/action_view/render/partials.rb b/actionpack/lib/action_view/render/partials.rb index f2429e8cef..eacf117bea 100644 --- a/actionpack/lib/action_view/render/partials.rb +++ b/actionpack/lib/action_view/render/partials.rb @@ -171,7 +171,7 @@ module ActionView # <% end %> module Partials extend ActiveSupport::Memoizable - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern included do attr_accessor :_partial diff --git a/activerecord/lib/active_record/aggregations.rb b/activerecord/lib/active_record/aggregations.rb index 359e70f5ed..9ecf231a66 100644 --- a/activerecord/lib/active_record/aggregations.rb +++ b/activerecord/lib/active_record/aggregations.rb @@ -1,6 +1,6 @@ module ActiveRecord module Aggregations # :nodoc: - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern def clear_aggregation_cache #:nodoc: self.class.reflect_on_all_aggregations.to_a.each do |assoc| diff --git a/activerecord/lib/active_record/association_preload.rb b/activerecord/lib/active_record/association_preload.rb index 5df76bb183..af80a579d6 100644 --- a/activerecord/lib/active_record/association_preload.rb +++ b/activerecord/lib/active_record/association_preload.rb @@ -1,7 +1,7 @@ module ActiveRecord # See ActiveRecord::AssociationPreload::ClassMethods for documentation. module AssociationPreload #:nodoc: - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern # Implements the details of eager loading of ActiveRecord associations. # Application developers should not use this module directly. diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 76726b7845..157716a477 100755 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -79,7 +79,7 @@ module ActiveRecord # See ActiveRecord::Associations::ClassMethods for documentation. module Associations # :nodoc: - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern # These classes will be loaded when associations are created. # So there is no need to eager load them. diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb index d5e215af9d..15358979c2 100644 --- a/activerecord/lib/active_record/attribute_methods.rb +++ b/activerecord/lib/active_record/attribute_methods.rb @@ -2,7 +2,7 @@ require 'active_support/core_ext/enumerable' module ActiveRecord module AttributeMethods #:nodoc: - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern DEFAULT_SUFFIXES = %w(= ? _before_type_cast) ATTRIBUTE_TYPES_CACHED_BY_DEFAULT = [:datetime, :timestamp, :time, :date] diff --git a/activerecord/lib/active_record/autosave_association.rb b/activerecord/lib/active_record/autosave_association.rb index 4ab2818282..ef9c40ed4d 100644 --- a/activerecord/lib/active_record/autosave_association.rb +++ b/activerecord/lib/active_record/autosave_association.rb @@ -125,7 +125,7 @@ module ActiveRecord # post.author.name = '' # post.save(false) # => true module AutosaveAssociation - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern ASSOCIATION_TYPES = %w{ has_one belongs_to has_many has_and_belongs_to_many } diff --git a/activerecord/lib/active_record/batches.rb b/activerecord/lib/active_record/batches.rb index 4836601297..e41d38fb8f 100644 --- a/activerecord/lib/active_record/batches.rb +++ b/activerecord/lib/active_record/batches.rb @@ -1,6 +1,6 @@ module ActiveRecord module Batches # :nodoc: - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern # When processing large numbers of records, it's often a good idea to do # so in batches to prevent memory ballooning. diff --git a/activerecord/lib/active_record/calculations.rb b/activerecord/lib/active_record/calculations.rb index 7afa7c49bd..727f4c1dc6 100644 --- a/activerecord/lib/active_record/calculations.rb +++ b/activerecord/lib/active_record/calculations.rb @@ -1,6 +1,6 @@ module ActiveRecord module Calculations #:nodoc: - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern CALCULATIONS_OPTIONS = [:conditions, :joins, :order, :select, :group, :having, :distinct, :limit, :offset, :include, :from] diff --git a/activerecord/lib/active_record/callbacks.rb b/activerecord/lib/active_record/callbacks.rb index a77fdb1c13..36f5f2ce47 100644 --- a/activerecord/lib/active_record/callbacks.rb +++ b/activerecord/lib/active_record/callbacks.rb @@ -211,7 +211,7 @@ module ActiveRecord # needs to be aware of it because an ordinary +save+ will raise such exception # instead of quietly returning +false+. module Callbacks - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern CALLBACKS = %w( after_find after_initialize before_save after_save before_create after_create before_update after_update before_validation diff --git a/activerecord/lib/active_record/dirty.rb b/activerecord/lib/active_record/dirty.rb index ac84f6b209..178767e0c3 100644 --- a/activerecord/lib/active_record/dirty.rb +++ b/activerecord/lib/active_record/dirty.rb @@ -34,7 +34,7 @@ module ActiveRecord # person.name << 'by' # person.name_change # => ['uncle bob', 'uncle bobby'] module Dirty - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern DIRTY_SUFFIXES = ['_changed?', '_change', '_will_change!', '_was'] diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb index 721114d9d0..2b0cfc2c3b 100644 --- a/activerecord/lib/active_record/fixtures.rb +++ b/activerecord/lib/active_record/fixtures.rb @@ -807,7 +807,7 @@ end module ActiveRecord module TestFixtures - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern included do setup :setup_fixtures diff --git a/activerecord/lib/active_record/locking/optimistic.rb b/activerecord/lib/active_record/locking/optimistic.rb index cf4f8864c6..cec5ca3324 100644 --- a/activerecord/lib/active_record/locking/optimistic.rb +++ b/activerecord/lib/active_record/locking/optimistic.rb @@ -42,7 +42,7 @@ module ActiveRecord # To override the name of the lock_version column, invoke the set_locking_column method. # This method uses the same syntax as set_table_name module Optimistic - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern included do cattr_accessor :lock_optimistically, :instance_writer => false diff --git a/activerecord/lib/active_record/named_scope.rb b/activerecord/lib/active_record/named_scope.rb index e7151a3d47..1b22fa5e24 100644 --- a/activerecord/lib/active_record/named_scope.rb +++ b/activerecord/lib/active_record/named_scope.rb @@ -3,7 +3,7 @@ require 'active_support/core_ext/hash/except' module ActiveRecord module NamedScope - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern # All subclasses of ActiveRecord::Base have one named scope: # * scoped - which allows for the creation of anonymous \scopes, on the fly: Shirt.scoped(:conditions => {:color => 'red'}).scoped(:include => :washing_instructions) diff --git a/activerecord/lib/active_record/nested_attributes.rb b/activerecord/lib/active_record/nested_attributes.rb index c532d3dfa3..0beb4321a2 100644 --- a/activerecord/lib/active_record/nested_attributes.rb +++ b/activerecord/lib/active_record/nested_attributes.rb @@ -3,7 +3,7 @@ require 'active_support/core_ext/object/try' module ActiveRecord module NestedAttributes #:nodoc: - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern included do class_inheritable_accessor :reject_new_nested_attributes_procs, :instance_writer => false diff --git a/activerecord/lib/active_record/observer.rb b/activerecord/lib/active_record/observer.rb index 1ca76c7b2f..89ec0962bf 100644 --- a/activerecord/lib/active_record/observer.rb +++ b/activerecord/lib/active_record/observer.rb @@ -3,7 +3,7 @@ require 'set' module ActiveRecord module Observing # :nodoc: - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern module ClassMethods # Activates the observers assigned. Examples: diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb index 3747ba449d..0baa9654b7 100644 --- a/activerecord/lib/active_record/reflection.rb +++ b/activerecord/lib/active_record/reflection.rb @@ -1,6 +1,6 @@ module ActiveRecord module Reflection # :nodoc: - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern # Reflection allows you to interrogate Active Record classes and objects about their associations and aggregations. # This information can, for example, be used in a form builder that took an Active Record object and created input diff --git a/activerecord/lib/active_record/serializers/json_serializer.rb b/activerecord/lib/active_record/serializers/json_serializer.rb index d376fd5e1b..67e2b2abb3 100644 --- a/activerecord/lib/active_record/serializers/json_serializer.rb +++ b/activerecord/lib/active_record/serializers/json_serializer.rb @@ -2,7 +2,7 @@ require 'active_support/json' module ActiveRecord #:nodoc: module Serialization - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern included do cattr_accessor :include_root_in_json, :instance_writer => false diff --git a/activerecord/lib/active_record/timestamp.rb b/activerecord/lib/active_record/timestamp.rb index 3734e170af..da075dabd3 100644 --- a/activerecord/lib/active_record/timestamp.rb +++ b/activerecord/lib/active_record/timestamp.rb @@ -8,7 +8,7 @@ module ActiveRecord # Timestamps are in the local timezone by default but you can use UTC by setting # ActiveRecord::Base.default_timezone = :utc module Timestamp - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern included do alias_method_chain :create, :timestamps diff --git a/activerecord/lib/active_record/transactions.rb b/activerecord/lib/active_record/transactions.rb index 471a81dfb5..4f8ccdd40e 100644 --- a/activerecord/lib/active_record/transactions.rb +++ b/activerecord/lib/active_record/transactions.rb @@ -3,7 +3,7 @@ require 'thread' module ActiveRecord # See ActiveRecord::Transactions::ClassMethods for documentation. module Transactions - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern class TransactionError < ActiveRecordError # :nodoc: end diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb index a18fb3f426..efc59908cf 100644 --- a/activerecord/lib/active_record/validations.rb +++ b/activerecord/lib/active_record/validations.rb @@ -302,7 +302,7 @@ module ActiveRecord # # An Errors object is automatically created for every Active Record. module Validations - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern VALIDATIONS = %w( validate validate_on_create validate_on_update ) diff --git a/activerecord/test/cases/associations/eager_load_nested_include_test.rb b/activerecord/test/cases/associations/eager_load_nested_include_test.rb index cb7fe9698b..f313a75233 100644 --- a/activerecord/test/cases/associations/eager_load_nested_include_test.rb +++ b/activerecord/test/cases/associations/eager_load_nested_include_test.rb @@ -7,7 +7,7 @@ require 'models/categorization' require 'active_support/core_ext/array/random_access' module Remembered - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern included do after_create :remember diff --git a/activerecord/test/cases/repair_helper.rb b/activerecord/test/cases/repair_helper.rb index 686bfee46d..80d04010d6 100644 --- a/activerecord/test/cases/repair_helper.rb +++ b/activerecord/test/cases/repair_helper.rb @@ -1,7 +1,7 @@ module ActiveRecord module Testing module RepairHelper - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern module Toolbox def self.record_validations(*model_classes) diff --git a/activesupport/lib/active_support/autoload.rb b/activesupport/lib/active_support/autoload.rb index ed229d1c5f..75706855d6 100644 --- a/activesupport/lib/active_support/autoload.rb +++ b/activesupport/lib/active_support/autoload.rb @@ -5,7 +5,7 @@ module ActiveSupport autoload :BufferedLogger, 'active_support/buffered_logger' autoload :Cache, 'active_support/cache' autoload :Callbacks, 'active_support/callbacks' - autoload :NewCallbacks, 'active_support/new_callbacks' + autoload :Concern, 'active_support/concern' autoload :ConcurrentHash, 'active_support/concurrent_hash' autoload :DependencyModule, 'active_support/dependency_module' autoload :Deprecation, 'active_support/deprecation' @@ -15,6 +15,7 @@ module ActiveSupport autoload :MessageEncryptor, 'active_support/message_encryptor' autoload :MessageVerifier, 'active_support/message_verifier' autoload :Multibyte, 'active_support/multibyte' + autoload :NewCallbacks, 'active_support/new_callbacks' autoload :OptionMerger, 'active_support/option_merger' autoload :OrderedHash, 'active_support/ordered_hash' autoload :OrderedOptions, 'active_support/ordered_options' diff --git a/activesupport/lib/active_support/concern.rb b/activesupport/lib/active_support/concern.rb new file mode 100644 index 0000000000..154f8807f7 --- /dev/null +++ b/activesupport/lib/active_support/concern.rb @@ -0,0 +1,22 @@ +require 'active_support/dependency_module' + +module ActiveSupport + module Concern + include DependencyModule + + def append_features(base) + if super + base.extend const_get("ClassMethods") if const_defined?("ClassMethods") + base.class_eval(&@_included_block) if instance_variable_defined?("@_included_block") + end + end + + def included(base = nil, &block) + if base.nil? + @_included_block = block + else + super + end + end + end +end diff --git a/activesupport/lib/active_support/dependency_module.rb b/activesupport/lib/active_support/dependency_module.rb index 9872b9654b..6847c0f86a 100644 --- a/activesupport/lib/active_support/dependency_module.rb +++ b/activesupport/lib/active_support/dependency_module.rb @@ -1,19 +1,9 @@ module ActiveSupport module DependencyModule def append_features(base) - return if base < self + return false if base < self (@_dependencies ||= []).each { |dep| base.send(:include, dep) } super - base.extend const_get("ClassMethods") if const_defined?("ClassMethods") - base.class_eval(&@_included_block) if instance_variable_defined?("@_included_block") - end - - def included(base = nil, &block) - if base.nil? - @_included_block = block - else - super - end end def depends_on(*mods) diff --git a/activesupport/test/dependency_module_test.rb b/activesupport/test/concern_test.rb similarity index 63% rename from activesupport/test/dependency_module_test.rb rename to activesupport/test/concern_test.rb index be7db0fa7b..22f7ec2064 100644 --- a/activesupport/test/dependency_module_test.rb +++ b/activesupport/test/concern_test.rb @@ -1,9 +1,9 @@ require 'abstract_unit' -require 'active_support/dependency_module' +require 'active_support/concern' -class DependencyModuleTest < Test::Unit::TestCase +class ConcernTest < Test::Unit::TestCase module Baz - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern module ClassMethods def baz @@ -29,7 +29,7 @@ class DependencyModuleTest < Test::Unit::TestCase end module Bar - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern depends_on Baz @@ -43,7 +43,7 @@ class DependencyModuleTest < Test::Unit::TestCase end module Foo - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern depends_on Bar, Baz end @@ -55,17 +55,17 @@ class DependencyModuleTest < Test::Unit::TestCase def test_module_is_included_normally @klass.send(:include, Baz) assert_equal "baz", @klass.new.baz - assert_equal DependencyModuleTest::Baz, @klass.included_modules[0] + assert_equal ConcernTest::Baz, @klass.included_modules[0] @klass.send(:include, Baz) assert_equal "baz", @klass.new.baz - assert_equal DependencyModuleTest::Baz, @klass.included_modules[0] + assert_equal ConcernTest::Baz, @klass.included_modules[0] end def test_class_methods_are_extended @klass.send(:include, Baz) assert_equal "baz", @klass.baz - assert_equal DependencyModuleTest::Baz::ClassMethods, (class << @klass; self.included_modules; end)[0] + assert_equal ConcernTest::Baz::ClassMethods, (class << @klass; self.included_modules; end)[0] end def test_included_block_is_ran @@ -78,11 +78,11 @@ class DependencyModuleTest < Test::Unit::TestCase assert_equal "bar", @klass.new.bar assert_equal "bar+baz", @klass.new.baz assert_equal "baz", @klass.baz - assert_equal [DependencyModuleTest::Bar, DependencyModuleTest::Baz], @klass.included_modules[0..1] + assert_equal [ConcernTest::Bar, ConcernTest::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] + assert_equal [ConcernTest::Foo, ConcernTest::Bar, ConcernTest::Baz], @klass.included_modules[0..2] end end