Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Psych::Visitors::ToRuby#resolve_subclass
resolve_subclass(klassname, parent)
ext/psych/lib/psych/visitors/to_ruby.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/ext/psych/lib/psych/visitors/to_ruby.rb, line 475
def resolve_subclass klassname, parent
klass = resolve_class(klassname)
if klass && !(klass <= parent)
raise ArgumentError, "Invalid tag: expected a subclass of #{parent}, got #{klass}"
end
klass
end
Resolve klassname and ensure it is parent or one of its subclasses. Tags such as !ruby/hash-with-ivars are only ever emitted for subclasses of a specific core class; without this check a crafted document could name an unrelated (but permitted) class and have its state populated directly, bypassing the class’s own init_with.