Skip to content

Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method · added in Ruby 3.2

Module#const_added

const_added(const_name)

Invoked as a callback whenever a constant is assigned on the receiver

Example
module Chatty
  def self.const_added(const_name)
    super
    puts "Added #{const_name.inspect}"
  end
  FOO = 1
end

produces:

Example
Added :FOO

Ruby version changes

  1. 3.2