Created
April 30, 2009 13:03
-
-
Save thinkerbot/104441 to your computer and use it in GitHub Desktop.
An attempt at YAML options
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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