Sha256: 3030adb636a15012c8dc9b3343acebdffdd6efe6843f7a5c74f6e6dfd7474e89

Contents?: true

Size: 1.14 KB

Versions: 7

Compression:

Stored size: 1.14 KB

Contents

require 'psych'

module Ruby3BackwardCompatibility
  module PsychCompatibility

    def self.prepended(by)
      by.singleton_class.prepend ClassMethods
    end

    module ClassMethods
      if Psych::VERSION >= '4'
        def load(...)
          unsafe_load(...)
        end
      end

      def safe_load(yaml, legacy_permitted_classes = NOT_GIVEN, legacy_permitted_symbols = NOT_GIVEN, legacy_aliases = NOT_GIVEN, legacy_filename = NOT_GIVEN, permitted_classes: [], permitted_symbols: [], aliases: false, filename: nil, **args)
        if legacy_permitted_classes != NOT_GIVEN
          permitted_classes = legacy_permitted_classes
        end
        if legacy_permitted_symbols != NOT_GIVEN
          permitted_symbols = legacy_permitted_symbols
        end
        if legacy_aliases != NOT_GIVEN
          aliases = legacy_aliases
        end
        if legacy_filename != NOT_GIVEN
          filename = legacy_filename
        end
        super(yaml, permitted_classes: permitted_classes, permitted_symbols: permitted_symbols, aliases: aliases, filename: filename, **args)
      end
    end
  end
end

Psych.prepend Ruby3BackwardCompatibility::PsychCompatibility

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ruby3-backward-compatibility-0.2.3 lib/ruby3_backward_compatibility/compatibility/psych.rb
ruby3-backward-compatibility-0.2.2 lib/ruby3_backward_compatibility/compatibility/psych.rb
ruby3-backward-compatibility-0.2.1 lib/ruby3_backward_compatibility/compatibility/psych.rb
ruby3-backward-compatibility-0.2.0 lib/ruby3_backward_compatibility/compatibility/psych.rb
ruby3-backward-compatibility-0.1.3 lib/ruby3_backward_compatibility/compatibility/psych.rb
ruby3-backward-compatibility-0.1.2 lib/ruby3_backward_compatibility/compatibility/psych.rb
ruby3-backward-compatibility-0.1.1 lib/ruby3_backward_compatibility/compatibility/psych.rb