File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed
Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change 2323require_relative 'psych/omap'
2424require_relative 'psych/set'
2525require_relative 'psych/coder'
26- require_relative 'psych/core_ext'
2726require_relative 'psych/stream'
2827require_relative 'psych/json/tree_builder'
2928require_relative 'psych/json/stream'
@@ -761,3 +760,5 @@ def domain_types=(value)
761760 self . domain_types = { }
762761 # :startdoc:
763762end
763+
764+ require_relative 'psych/core_ext'
Original file line number Diff line number Diff line change @@ -18,12 +18,19 @@ def to_yaml options = {}
1818 require_relative 'y'
1919end
2020
21-
22- # TODO: how best to check for builtin Set?
23- if defined? ( ::Set ) && Object . const_source_location ( :Set ) == [ "ruby" , 0 ]
21+ # Up to Ruby 3.4, Set was a regular object and was dumped as such
22+ # by Pysch.
23+ # Starting from Ruby 3.5 it's a core class written in C, so we have to implement
24+ # #encode_with / #init_with to preserve backward compatibility.
25+ if defined? ( ::Set ) && Set . new . instance_variables . empty?
2426 class Set
2527 def encode_with ( coder )
26- coder [ "hash" ] = to_h
28+ hash = { }
29+ each do |m |
30+ hash [ m ] = true
31+ end
32+ coder [ "hash" ] = hash
33+ coder
2734 end
2835
2936 def init_with ( coder )
You can’t perform that action at this time.
0 commit comments