Skip to content

Commit

Permalink
Merge pull request #38917 from eugeneius/rm_active_record_define_call…
Browse files Browse the repository at this point in the history
…backs

Remove ActiveRecord::DefineCallbacks module
  • Loading branch information
eugeneius committed Apr 10, 2020
2 parents 6d6d4b9 + 6517263 commit fb4a3fb
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 25 deletions.
2 changes: 0 additions & 2 deletions activerecord/lib/active_record/base.rb
Expand Up @@ -6,7 +6,6 @@
require "active_support/time"
require "active_support/core_ext/class/subclasses"
require "active_record/attribute_decorators"
require "active_record/define_callbacks"
require "active_record/log_subscriber"
require "active_record/explain_subscriber"
require "active_record/relation/delegation"
Expand Down Expand Up @@ -296,7 +295,6 @@ class Base
include AttributeDecorators
include Locking::Optimistic
include Locking::Pessimistic
include DefineCallbacks
include AttributeMethods
include Callbacks
include Timestamp
Expand Down
11 changes: 11 additions & 0 deletions activerecord/lib/active_record/callbacks.rb
Expand Up @@ -301,6 +301,17 @@ module Callbacks
:before_destroy, :around_destroy, :after_destroy, :after_commit, :after_rollback
]

module ClassMethods # :nodoc:
include ActiveModel::Callbacks
end

included do
include ActiveModel::Validations::Callbacks

define_model_callbacks :initialize, :find, :touch, only: :after
define_model_callbacks :save, :create, :update, :destroy
end

def destroy #:nodoc:
@_destroy_callback_already_called ||= false
return if @_destroy_callback_already_called
Expand Down
22 changes: 0 additions & 22 deletions activerecord/lib/active_record/define_callbacks.rb

This file was deleted.

1 change: 0 additions & 1 deletion activerecord/test/cases/attribute_methods/read_test.rb
Expand Up @@ -16,7 +16,6 @@ def self.superclass; Base; end
def self.base_class?; true; end
def self.decorate_matching_attribute_types(*); end

include ActiveRecord::DefineCallbacks
include ActiveRecord::AttributeMethods

def self.attribute_names
Expand Down

0 comments on commit fb4a3fb

Please sign in to comment.