Sha256: f5f70506cf349e83f748eeedb8ed3c479a227fb404ca42f25f6284cc8a1ac279

Contents?: true

Size: 990 Bytes

Versions: 127

Compression:

Stored size: 990 Bytes

Contents

# frozen_string_literal: true

require 'active_support/callbacks'
require 'eac_ruby_utils/core_ext'

module Avm
  module Data
    module Callbacks
      common_concern do
        include ::ActiveSupport::Callbacks

        %i[dump load].each do |action|
          define_callbacks action

          %i[before after].each do |callback|
            method_name = "#{callback}_#{action}"
            singleton_class.class_eval do
              define_method method_name do |callback_method = nil, &block|
                if callback_method
                  set_callback action, callback, callback_method
                else
                  set_callback action, callback, &block
                end
                self
              end
            end

            define_method method_name do |callback_method = nil, &block|
              singleton_class.send(method_name, callback_method, &block)
              self
            end
          end
        end
      end
    end
  end
end

Version data entries

127 entries across 127 versions & 2 rubygems

Version Path
avm-0.94.0 lib/avm/data/callbacks.rb
eac_tools-0.94.0 sub/avm/lib/avm/data/callbacks.rb
avm-0.93.0 lib/avm/data/callbacks.rb
eac_tools-0.92.0 sub/avm/lib/avm/data/callbacks.rb
avm-0.92.0 lib/avm/data/callbacks.rb
eac_tools-0.91.0 sub/avm/lib/avm/data/callbacks.rb
avm-0.90.1 lib/avm/data/callbacks.rb
eac_tools-0.87.1 sub/avm/lib/avm/data/callbacks.rb
avm-0.90.0 lib/avm/data/callbacks.rb
eac_tools-0.87.0 sub/avm/lib/avm/data/callbacks.rb
avm-0.89.0 lib/avm/data/callbacks.rb
eac_tools-0.86.12 sub/avm/lib/avm/data/callbacks.rb
avm-0.88.0 lib/avm/data/callbacks.rb
eac_tools-0.86.11 sub/avm/lib/avm/data/callbacks.rb
avm-0.87.0 lib/avm/data/callbacks.rb
eac_tools-0.86.8 sub/avm/lib/avm/data/callbacks.rb
avm-0.86.2 lib/avm/data/callbacks.rb
eac_tools-0.86.7 sub/avm/lib/avm/data/callbacks.rb
avm-0.86.1 lib/avm/data/callbacks.rb
eac_tools-0.86.5 sub/avm/lib/avm/data/callbacks.rb