Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
An attempt at YAML options
# Setting options for to_yaml doesn't work.
# * http://www.arkanis-development.de/weblog/2007/6/20/options-for-rubys-@to_yaml@-method
# * http://groups.google.com/group/ruby-talk-google/browse_thread/thread/b9bd01242f7d67ae/7186dd14f9e1e3ff#7186dd14f9e1e3ff
#
# This is an attempt to workaround by directly setting a flag in the
# emitter. Fail. If I recall right, trying to set/modify the @options
# hash also does not work.
#
# :UseHeader => false
#
module YAML
def YAML.emitter
nil
end
end
e = YAML::Syck::Emitter.new(
:UseHeader => false,
:use_header => false,
'UseHeader' => false,
'use_header' => false
).set_resolver( YAML.resolver )
puts [1,2,3].to_yaml(e)
puts e.instance_variable_get(:@options)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.