Sha256: e4d9eea6543b6390b45d9b33ab32a44ef91e1aa712ff10705e56de98b89ef0d4
Contents?: true
Size: 903 Bytes
Versions: 17
Compression:
Stored size: 903 Bytes
Contents
require "yaml" class String def is_binary_data? false end end module YamlWaml def decode(orig_yamled) yamled_str = case orig_yamled when String then orig_yamled when StringIO then orig_yamled.string else return orig_yamled end yamled_str.gsub!(/\\x(\w{2})/){[$1].pack("H2")} return yamled_str end module_function :decode end ObjectSpace.each_object(Class) do |klass| klass.class_eval do if method_defined?(:to_yaml) && !method_defined?(:to_yaml_with_decode) def to_yaml_with_decode(*args) io = args.shift if IO === args.first yamled_str = YamlWaml.decode(to_yaml_without_decode(*args)) io.write(yamled_str) if io return yamled_str end alias_method :to_yaml_without_decode, :to_yaml alias_method :to_yaml, :to_yaml_with_decode end end end
Version data entries
17 entries across 17 versions & 4 rubygems