mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
require Psych if possible, use Psych output when enabled
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
begin
|
||||
require 'psych'
|
||||
rescue LoadError
|
||||
end
|
||||
|
||||
require 'yaml'
|
||||
|
||||
YAML.add_builtin_type("omap") do |type, val|
|
||||
@@ -20,9 +25,17 @@ module ActiveSupport
|
||||
"!tag:yaml.org,2002:omap"
|
||||
end
|
||||
|
||||
def encode_with(coder)
|
||||
coder.represent_seq '!omap', map { |k,v| { k => v } }
|
||||
end
|
||||
|
||||
def to_yaml(opts = {})
|
||||
if YAML.const_defined?(:ENGINE) && !YAML::ENGINE.syck?
|
||||
return super
|
||||
end
|
||||
|
||||
YAML.quick_emit(self, opts) do |out|
|
||||
out.seq(taguri, to_yaml_style) do |seq|
|
||||
out.seq(taguri) do |seq|
|
||||
each do |k, v|
|
||||
seq.add(k => v)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user