Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

rails_callback_ex

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rails_callback_ex

bundlerRubyGems.org
Version
0.2.0
Version published
Maintainers
1
Created
Source

RailsCallbackEx

Insert/delete callbacks for rails.

Dependencies

  • ruby 3.0+
  • rails 7.0+

Installation

Add this line to your application's Gemfile:

gem 'rails_callback_ex'

Then execute:

$ bundle

Usage

Controller

Example:

class SamplesController < ActionController::Base
  before_action :action1
  before_action :action2

  insert_before_action :new_action1, before: :action1
  insert_before_action :new_action2, after: :action1
end

SamplesController.__callbacks[:process_action].map(&:filter) #=> [:new_action1, :action1, :new_action2, :action2]

SamplesController.delete_before_action :new_action1

SamplesController.__callbacks[:process_action].map(&:filter) #=> [:action1, :new_action2, :action2]

Model

Example:

class Sample < ActiveRecord::Base
  before_save :action1
  before_save :action2

  insert_before_save :new_action1, before: :action1
  insert_before_save :new_action2, after: :action1
end

Sample.__callbacks[:save].map(&:filter) #=> [:new_action1, :action1, :new_action2, :action2]

Sample.delete_before_save :new_action1

Sample.__callbacks[:save].map(&:filter) #=> [:action1, :new_action2, :action2]

Supported callbacks are validation, save, create, update and destroy.

Job

Example:

class SampleJob < ActiveJob::Base
  before_perform :action1
  before_perform :action2

  insert_before_perform :new_action1, before: :action1
  insert_before_perform :new_action2, after: :action1
end

SampleJob.__callbacks[:perform].map(&:filter) #=> [:new_action1, :action1, :new_action2, :action2]

SampleJob.delete_before_perform :new_action1

SampleJob.__callbacks[:perform].map(&:filter) #=> [:action1, :new_action2, :action2]

Supported callbacks are enqueue and perform.

Mailer

Example:

class SampleMailer < ActionMailer::Base
  before_deliver :action1
  before_deliver :action2

  insert_before_deliver :new_action1, before: :action1
  insert_before_deliver :new_action2, after: :action1
end

SampleMailer.__callbacks[:deliver].map(&:filter) #=> [:new_action1, :action1, :new_action2, :action2]

SampleMailer.delete_before_deliver :new_action1

SampleMailer.__callbacks[:deliver].map(&:filter) #=> [:action1, :new_action2, :action2]

Supported callback is deliver. Note that deliver callbacks can be used on rails >= 7.1.

Contributing

Bug reports and pull requests are welcome at https://github.com/kanety/rails_callback_ex.

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 06 Jan 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts