summaryrefslogtreecommitdiff
path: root/object.c
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2025-02-16 20:30:40 +0100
committerJean Boussier <jean.boussier@gmail.com>2025-04-10 10:33:36 +0200
commit08ce6268ee1690f003af40b9357272d43e990d75 (patch)
tree0d04ac6c12879fa0d80e4a387561f1bd51541a1d /object.c
parentb47a04eb9151a9fa59979fbaf20deeb404822959 (diff)
Document order of execution const_added vs inherited
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/12759
Diffstat (limited to 'object.c')
-rw-r--r--object.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/object.c b/object.c
index 74f58a15bd..5a379e9d08 100644
--- a/object.c
+++ b/object.c
@@ -1193,6 +1193,30 @@ rb_class_search_ancestor(VALUE cl, VALUE c)
*
* Added :FOO
*
+ * If we define a class using the <tt>class</tt> keyword, <tt>const_added</tt>
+ * runs before <tt>inherited</tt>:
+ *
+ * module M
+ * def self.const_added(const_name)
+ * super
+ * p :const_added
+ * end
+ *
+ * parent = Class.new do
+ * def self.inherited(subclass)
+ * super
+ * p :inherited
+ * end
+ * end
+ *
+ * class Child < parent
+ * end
+ * end
+ *
+ * <em>produces:</em>
+ *
+ * :const_added
+ * :inherited
*/
#define rb_obj_mod_const_added rb_obj_dummy1