Skip to content

Instantly share code, notes, and snippets.

@thinkerbot
Created April 30, 2009 13:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thinkerbot/104441 to your computer and use it in GitHub Desktop.
Save thinkerbot/104441 to your computer and use it in GitHub Desktop.
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