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
eac_tools-0.69.1 sub/avm/lib/avm/data/callbacks.rb
avm-0.75.0 lib/avm/data/callbacks.rb
eac_tools-0.69.0 sub/avm/lib/avm/data/callbacks.rb
avm-0.74.0 lib/avm/data/callbacks.rb
eac_tools-0.68.0 sub/avm/lib/avm/data/callbacks.rb
avm-0.73.1 lib/avm/data/callbacks.rb
eac_tools-0.67.1 sub/avm/lib/avm/data/callbacks.rb
avm-0.73.0 lib/avm/data/callbacks.rb
eac_tools-0.67.0 sub/avm/lib/avm/data/callbacks.rb
avm-0.72.0 lib/avm/data/callbacks.rb
eac_tools-0.66.0 sub/avm/lib/avm/data/callbacks.rb
eac_tools-0.65.1 sub/avm/lib/avm/data/callbacks.rb
avm-0.71.0 lib/avm/data/callbacks.rb
eac_tools-0.65.0 sub/avm/lib/avm/data/callbacks.rb
avm-0.70.0 lib/avm/data/callbacks.rb
eac_tools-0.64.0 sub/avm/lib/avm/data/callbacks.rb
avm-0.69.0 lib/avm/data/callbacks.rb
eac_tools-0.63.0 sub/avm/lib/avm/data/callbacks.rb
eac_tools-0.62.1 sub/avm/lib/avm/data/callbacks.rb
avm-0.68.0 lib/avm/data/callbacks.rb