
Issue #19450 has been updated by zverok (Victor Shepelev). Just an aside note: ActiveRecord models [redefine](https://github.com/rails/rails/blob/main/activerecord/lib/active_record/core...) `#inspect` (and not `#name`) to achieve "informative description" effect: ```ruby p User User(id: integer, email: citext, name: string, time_zone: string, ...) ``` For me, it seems more reasonable than redefining `#name` (like, `Class#name` has an implicit contract of "being reachable by the name, considered as a name of a constant containing the class). ---------------------------------------- Feature #19450: Is there an official way to set a class name without setting a constant? https://bugs.ruby-lang.org/issues/19450#change-101957 * Author: ioquatix (Samuel Williams) * Status: Open * Priority: Normal ---------------------------------------- This is the best I could come up with: ```ruby klass = Class.new Object.const_set("Klass", klass) Object.send(:remove_const, "Klass") puts klass.new # => #<Klass:0x0000000100a9d688> ``` Can we do better? What about something like: ```ruby Class.new(name: "Klass") ``` or ```ruby Class.new do def self.name "Klass" end end ``` etc -- https://bugs.ruby-lang.org/