diff options
-rw-r--r-- | lib/pp.rb | 23 |
1 files changed, 18 insertions, 5 deletions
@@ -93,11 +93,24 @@ class PP < PrettyPrint end # :startdoc: - @sharing_detection = false - class << self - # Returns the sharing detection flag as a boolean value. - # It is false by default. - attr_accessor :sharing_detection + if defined? ::Ractor + class << self + # Returns the sharing detection flag as a boolean value. + # It is false (nil) by default. + def sharing_detection + Ractor.current[:pp_sharing_detection] + end + def sharing_detection=(b) + Ractor.current[:pp_sharing_detection] = b + end + end + else + @sharing_detection = false + class << self + # Returns the sharing detection flag as a boolean value. + # It is false by default. + attr_accessor :sharing_detection + end end module PPMethods |