Sha256: 15b342d0b7615d25c5f42f5250e4e1a050745eec60c56d64c2ee63ebcacd6c77

Contents?: true

Size: 719 Bytes

Versions: 3

Compression:

Stored size: 719 Bytes

Contents

# frozen_string_literal: true

module ActiveShotgun
  module Model
    module Callbacks
      def self.prepended(base)
        base.define_model_callbacks :destroy
        base.define_model_callbacks :update
        base.define_model_callbacks :save
        base.define_model_callbacks :create
        base.define_model_callbacks :validation
      end

      def destroy
        run_callbacks(:destroy) do
          super
        end
      end

      def save
        run_callbacks(:save) do
          run_callbacks(persisted? ? :update : :create) do
            super
          end
        end
      end

      def validate
        run_callbacks(:validation) do
          super
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
active_shotgun-0.0.4 lib/active_shotgun/model/callbacks.rb
active_shotgun-0.0.3 lib/active_shotgun/model/callbacks.rb
active_shotgun-0.0.2.1 lib/active_shotgun/model/callbacks.rb