we4tech/flexi-model

View on GitHub
lib/flexi_model/callbacks.rb

Summary

Maintainability
A
0 mins
Test Coverage
module FlexiModel
  module Callbacks
    extend ActiveSupport::Concern

    included do
      extend ActiveModel::Callbacks
      include ActiveModel::Validations::Callbacks

      # Set callbacks
      define_model_callbacks :save, :create, :update, :destroy, :initialize
    end
  end

  def initialize(*)
    run_callbacks(:initialize) { super }
  end

  def save
    run_callbacks(:save) { super }
  end

  def create
    run_callbacks(:create) { super }
  end

  def update(*)
    run_callbacks(:update) { super }
  end

  def update_attributes(*)
    run_callbacks(:update) { super }
  end

  def update_attribute(*)
    run_callbacks(:update) { super }
  end

  def destroy
    run_callbacks(:destroy) { super }
  end
end