aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/define_callbacks.rb
blob: 2c8783dcc9fada118bc684ebab8b31fe4ee6e39a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true

module ActiveRecord
  # This module exists because `ActiveRecord::AttributeMethods::Dirty` needs to
  # define callbacks, but continue to have its version of `save` be the super
  # method of `ActiveRecord::Callbacks`. This will be removed when the removal
  # of deprecated code removes this need.
  module DefineCallbacks
    extend ActiveSupport::Concern

    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
  end
end