summaryrefslogtreecommitdiff
path: root/ext/psych/lib/psych
diff options
context:
space:
mode:
Diffstat (limited to 'ext/psych/lib/psych')
-rw-r--r--ext/psych/lib/psych/deprecated.rb14
-rw-r--r--ext/psych/lib/psych/visitors/to_ruby.rb2
2 files changed, 15 insertions, 1 deletions
diff --git a/ext/psych/lib/psych/deprecated.rb b/ext/psych/lib/psych/deprecated.rb
index fdff46845d..b306b85bce 100644
--- a/ext/psych/lib/psych/deprecated.rb
+++ b/ext/psych/lib/psych/deprecated.rb
@@ -36,6 +36,20 @@ module Psych
return 'null' if '' == thing
ScalarScanner.new.tokenize(thing).class.name.downcase
end
+
+ def self.add_ruby_type type_tag, &block
+ warn "#{caller[0]}: add_ruby_type is deprecated, use add_domain_type" if $VERBOSE
+ domain = 'ruby.yaml.org,2002'
+ key = ['tag', domain, type_tag].join ':'
+ @domain_types[key] = [key, block]
+ end
+
+ def self.add_private_type type_tag, &block
+ warn "#{caller[0]}: add_private_type is deprecated, use add_domain_type" if $VERBOSE
+ domain = 'x-private'
+ key = [domain, type_tag].join ':'
+ @domain_types[key] = [key, block]
+ end
end
class Object
diff --git a/ext/psych/lib/psych/visitors/to_ruby.rb b/ext/psych/lib/psych/visitors/to_ruby.rb
index bbbe9a8366..e28ac7bf87 100644
--- a/ext/psych/lib/psych/visitors/to_ruby.rb
+++ b/ext/psych/lib/psych/visitors/to_ruby.rb
@@ -17,7 +17,7 @@ module Psych
return result if @domain_types.empty? || !target.tag
key = target.tag.sub(/^[!\/]*/, '').sub(/(,\d+)\//, '\1:')
- key = "tag:#{key}" unless key.start_with?('tag:')
+ key = "tag:#{key}" unless key =~ /^(tag:|x-private)/
if @domain_types.key? key
value, block = @domain_types[key]