Sha256: 363575a7f7e2cebb17d17d2e221d653007c144bad1229f45d7b074c78622c4c9

Contents?: true

Size: 749 Bytes

Versions: 1

Compression:

Stored size: 749 Bytes

Contents

require_relative "./action_callback/version"
require_relative "./action_callback/define_callback"
require_relative "./action_callback/callback"
require_relative "./action_callback/define_validation"
require_relative "./action_callback/validation"

module ActionCallback
  include Callback
  include Validation
  extend self

  def ActionCallback.extended(mod)
    initialize_callback_chain(mod)

    [:before, :after].each do |callback|
      define_callback(callback)
      alias_method :"#{callback}_filter", :"#{callback}_action"
    end

    initialize_validation_chain(mod)
    define_validation
  end
end

if defined?(Rails)
  base_model = Rails.version >= '5.0' ? ApplicationRecord : ActiveRecord::Base
  base_model.extend(ActionCallback)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
action_callback-0.3.0 lib/action_callback.rb