Permalink
Browse files

Break up DependencyModule's dual function of providing a "depend_on" …

…DSL and "included" block DSL into separate modules. But, unify both approaches under AS::Concern.
  • Loading branch information...
1 parent de20324 commit 4e50a35fa243f6cf7ad567774a9f7c1cb87a1653 @josh josh committed May 28, 2009
Showing with 98 additions and 89 deletions.
  1. +1 −1 actionpack/lib/action_controller/abstract/benchmarker.rb
  2. +1 −1 actionpack/lib/action_controller/abstract/callbacks.rb
  3. +1 −1 actionpack/lib/action_controller/abstract/helpers.rb
  4. +1 −1 actionpack/lib/action_controller/abstract/layouts.rb
  5. +1 −1 actionpack/lib/action_controller/abstract/logger.rb
  6. +1 −1 actionpack/lib/action_controller/abstract/renderer.rb
  7. +1 −1 actionpack/lib/action_controller/base/chained/flash.rb
  8. +1 −1 actionpack/lib/action_controller/base/filter_parameter_logging.rb
  9. +1 −1 actionpack/lib/action_controller/base/helpers.rb
  10. +1 −1 actionpack/lib/action_controller/base/request_forgery_protection.rb
  11. +1 −1 actionpack/lib/action_controller/base/streaming.rb
  12. +1 −1 actionpack/lib/action_controller/base/verification.rb
  13. +1 −1 actionpack/lib/action_controller/caching.rb
  14. +1 −1 actionpack/lib/action_controller/new_base/compatibility.rb
  15. +1 −1 actionpack/lib/action_controller/new_base/conditional_get.rb
  16. +1 −1 actionpack/lib/action_controller/new_base/helpers.rb
  17. +1 −1 actionpack/lib/action_controller/new_base/hide_actions.rb
  18. +1 −1 actionpack/lib/action_controller/new_base/layouts.rb
  19. +1 −1 actionpack/lib/action_controller/new_base/rack_convenience.rb
  20. +16 −20 actionpack/lib/action_controller/new_base/render_options.rb
  21. +1 −1 actionpack/lib/action_controller/new_base/renderer.rb
  22. +1 −1 actionpack/lib/action_controller/new_base/rescuable.rb
  23. +1 −1 actionpack/lib/action_controller/new_base/session.rb
  24. +1 −1 actionpack/lib/action_controller/new_base/testing.rb
  25. +1 −1 actionpack/lib/action_controller/new_base/url_for.rb
  26. +1 −1 actionpack/lib/action_controller/testing/integration.rb
  27. +1 −1 actionpack/lib/action_view/render/partials.rb
  28. +1 −1 activerecord/lib/active_record/aggregations.rb
  29. +1 −1 activerecord/lib/active_record/association_preload.rb
  30. +1 −1 activerecord/lib/active_record/associations.rb
  31. +1 −1 activerecord/lib/active_record/attribute_methods.rb
  32. +1 −1 activerecord/lib/active_record/autosave_association.rb
  33. +1 −1 activerecord/lib/active_record/batches.rb
  34. +1 −1 activerecord/lib/active_record/calculations.rb
  35. +1 −1 activerecord/lib/active_record/callbacks.rb
  36. +1 −1 activerecord/lib/active_record/dirty.rb
  37. +1 −1 activerecord/lib/active_record/fixtures.rb
  38. +1 −1 activerecord/lib/active_record/locking/optimistic.rb
  39. +1 −1 activerecord/lib/active_record/named_scope.rb
  40. +1 −1 activerecord/lib/active_record/nested_attributes.rb
  41. +1 −1 activerecord/lib/active_record/observer.rb
  42. +1 −1 activerecord/lib/active_record/reflection.rb
  43. +1 −1 activerecord/lib/active_record/serializers/json_serializer.rb
  44. +1 −1 activerecord/lib/active_record/timestamp.rb
  45. +1 −1 activerecord/lib/active_record/transactions.rb
  46. +1 −1 activerecord/lib/active_record/validations.rb
  47. +1 −1 activerecord/test/cases/associations/eager_load_nested_include_test.rb
  48. +1 −1 activerecord/test/cases/repair_helper.rb
  49. +2 −1 activesupport/lib/active_support/autoload.rb
  50. +22 −0 activesupport/lib/active_support/concern.rb
  51. +1 −11 activesupport/lib/active_support/dependency_module.rb
  52. +10 −10 activesupport/test/{dependency_module_test.rb → concern_test.rb}
@@ -1,6 +1,6 @@
module AbstractController
module Benchmarker
- extend ActiveSupport::DependencyModule
+ extend ActiveSupport::Concern
depends_on Logger
@@ -1,6 +1,6 @@
module AbstractController
module Callbacks
- extend ActiveSupport::DependencyModule
+ extend ActiveSupport::Concern
depends_on ActiveSupport::NewCallbacks
@@ -1,6 +1,6 @@
module AbstractController
module Helpers
- extend ActiveSupport::DependencyModule
+ extend ActiveSupport::Concern
depends_on Renderer
@@ -1,6 +1,6 @@
module AbstractController
module Layouts
- extend ActiveSupport::DependencyModule
+ extend ActiveSupport::Concern
depends_on Renderer
@@ -3,7 +3,7 @@
module AbstractController
module Logger
- extend ActiveSupport::DependencyModule
+ extend ActiveSupport::Concern
class DelayedLog
def initialize(&blk)
@@ -2,7 +2,7 @@
module AbstractController
module Renderer
- extend ActiveSupport::DependencyModule
+ extend ActiveSupport::Concern
depends_on AbstractController::Logger
@@ -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)
@@ -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)
@@ -3,7 +3,7 @@
# 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.
@@ -3,7 +3,7 @@ class InvalidAuthenticityToken < ActionControllerError #: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)
@@ -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)
@@ -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)
@@ -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'
@@ -1,6 +1,6 @@
module ActionController
module Rails2Compatibility
- extend ActiveSupport::DependencyModule
+ extend ActiveSupport::Concern
class ::ActionController::ActionControllerError < StandardError #:nodoc:
end
@@ -1,6 +1,6 @@
module ActionController
module ConditionalGet
- extend ActiveSupport::DependencyModule
+ extend ActiveSupport::Concern
depends_on RackConvenience
@@ -4,7 +4,7 @@
module ActionController
module Helpers
- extend ActiveSupport::DependencyModule
+ extend ActiveSupport::Concern
depends_on AbstractController::Helpers
@@ -1,6 +1,6 @@
module ActionController
module HideActions
- extend ActiveSupport::DependencyModule
+ extend ActiveSupport::Concern
included do
extlib_inheritable_accessor :hidden_actions
@@ -1,6 +1,6 @@
module ActionController
module Layouts
- extend ActiveSupport::DependencyModule
+ extend ActiveSupport::Concern
depends_on ActionController::Renderer
depends_on AbstractController::Layouts
@@ -1,6 +1,6 @@
module ActionController
module RackConvenience
- extend ActiveSupport::DependencyModule
+ extend ActiveSupport::Concern
included do
delegate :headers, :status=, :location=,
@@ -1,6 +1,6 @@
module ActionController
module RenderOptions
- extend ActiveSupport::DependencyModule
+ extend ActiveSupport::Concern
included do
extlib_inheritable_accessor :_renderers
@@ -36,22 +36,20 @@ def render_to_body(options)
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
end
module Renderers
module Json
- include RenderOption
+ extend RenderOption
register_renderer :json
def _render_json(json, options)
@@ -63,7 +61,7 @@ def _render_json(json, options)
end
module Js
- include RenderOption
+ extend RenderOption
register_renderer :js
def _render_js(js, options)
@@ -73,7 +71,7 @@ def _render_js(js, options)
end
module Xml
- include RenderOption
+ extend RenderOption
register_renderer :xml
def _render_xml(xml, options)
@@ -82,8 +80,8 @@ def _render_xml(xml, options)
end
end
- module Rjs
- include RenderOption
+ module RJS
+ extend RenderOption
register_renderer :update
def _render_update(proc, options)
@@ -94,14 +92,12 @@ def _render_update(proc, options)
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
@@ -1,6 +1,6 @@
module ActionController
module Renderer
- extend ActiveSupport::DependencyModule
+ extend ActiveSupport::Concern
depends_on AbstractController::Renderer
@@ -15,7 +15,7 @@ module ActionController #:nodoc:
# behavior is achieved by overriding the <tt>rescue_action_in_public</tt>
# and <tt>rescue_action_locally</tt> methods.
module Rescue
- extend ActiveSupport::DependencyModule
+ extend ActiveSupport::Concern
included do
include ActiveSupport::Rescuable
@@ -1,6 +1,6 @@
module ActionController
module Session
- extend ActiveSupport::DependencyModule
+ extend ActiveSupport::Concern
depends_on RackConvenience
@@ -1,6 +1,6 @@
module ActionController
module Testing
- extend ActiveSupport::DependencyModule
+ extend ActiveSupport::Concern
depends_on RackConvenience
@@ -1,6 +1,6 @@
module ActionController
module UrlFor
- extend ActiveSupport::DependencyModule
+ extend ActiveSupport::Concern
depends_on RackConvenience
@@ -301,7 +301,7 @@ def generic_url_rewriter
# 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
@@ -171,7 +171,7 @@ module ActionView
# <% end %>
module Partials
extend ActiveSupport::Memoizable
- extend ActiveSupport::DependencyModule
+ extend ActiveSupport::Concern
included do
attr_accessor :_partial
@@ -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|
@@ -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.
@@ -79,7 +79,7 @@ def initialize(reflection)
# 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.
@@ -2,7 +2,7 @@
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]
@@ -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 }
@@ -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.
@@ -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]
@@ -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
@@ -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']
@@ -807,7 +807,7 @@ def find
module ActiveRecord
module TestFixtures
- extend ActiveSupport::DependencyModule
+ extend ActiveSupport::Concern
included do
setup :setup_fixtures
Oops, something went wrong.

0 comments on commit 4e50a35

Please sign in to comment.