aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/model.rb
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2012-10-19 18:08:51 +0100
committerJon Leighton <j@jonathanleighton.com>2012-10-19 18:12:54 +0100
commit83846838252397b3781eed165ca301e05db39293 (patch)
tree871c8e6734e82a1d2d6ce9122c5870b80d9f9cfc /activerecord/lib/active_record/model.rb
parent18e979eea3844a9d293a547528d40ffde198b719 (diff)
downloadrails-83846838252397b3781eed165ca301e05db39293.tar.gz
rails-83846838252397b3781eed165ca301e05db39293.tar.bz2
rails-83846838252397b3781eed165ca301e05db39293.zip
Get rid of the ActiveRecord::Model::DeprecationProxy thing.
I think it's going to be too much pain to try to transition the :active_record load hook from executing against Base to executing against Model. For example, after Model is included in Base, and modules included in Model will no longer get added to the ancestors of Base. So plugins which wish to be compatible with both Model and Base should use the :active_record_model load hook which executes *before* Base gets loaded. In general, ActiveRecord::Model is an advanced feature at the moment and probably most people will continue to inherit from ActiveRecord::Base for the time being.
Diffstat (limited to 'activerecord/lib/active_record/model.rb')
-rw-r--r--activerecord/lib/active_record/model.rb45
1 files changed, 7 insertions, 38 deletions
diff --git a/activerecord/lib/active_record/model.rb b/activerecord/lib/active_record/model.rb
index f059840f4d..5fcb0359c5 100644
--- a/activerecord/lib/active_record/model.rb
+++ b/activerecord/lib/active_record/model.rb
@@ -115,52 +115,21 @@ module ActiveRecord
'type'
end
end
-
- class DeprecationProxy < BasicObject #:nodoc:
- def initialize(model = Model, base = Base)
- @model = model
- @base = base
- end
-
- def method_missing(name, *args, &block)
- if @model.respond_to?(name, true)
- @model.send(name, *args, &block)
- else
- ::ActiveSupport::Deprecation.warn(
- "The object passed to the active_record load hook was previously ActiveRecord::Base " \
- "(a Class). Now it is ActiveRecord::Model (a Module). You have called `#{name}' which " \
- "is only defined on ActiveRecord::Base. Please change your code so that it works with " \
- "a module rather than a class. (Model is included in Base, so anything added to Model " \
- "will be available on Base as well.)"
- )
- @base.send(name, *args, &block)
- end
- end
-
- alias send method_missing
-
- def extend(*mods)
- ::ActiveSupport::Deprecation.warn(
- "The object passed to the active_record load hook was previously ActiveRecord::Base " \
- "(a Class). Now it is ActiveRecord::Model (a Module). You have called `extend' which " \
- "would add singleton methods to Model. This is presumably not what you want, since the " \
- "methods would not be inherited down to Base. Rather than using extend, please use " \
- "ActiveSupport::Concern + include, which will ensure that your class methods are " \
- "inherited."
- )
- @base.extend(*mods)
- end
- end
end
- # This hook is where config accessors on Model get defined.
+ # This hook is where config accessors on Model should be defined.
#
# We don't want to just open the Model module and add stuff to it in other files, because
# that would cause Model to load, which causes all sorts of loading order issues.
#
# We need this hook rather than just using the :active_record one, because users of the
# :active_record hook may need to use config options.
- ActiveSupport.run_load_hooks(:active_record_config, Model)
+ #
+ # Users who wish to include a module in Model that they want to also
+ # get inherited by Base should do so using this load hook. After Base
+ # has included Model, any modules subsequently included in Model won't
+ # be inherited by Base.
+ ActiveSupport.run_load_hooks(:active_record_model, Model)
# Load Base at this point, because the active_record load hook is run in that file.
Base