Inject to_toml methods into the Ruby classes used by TOML (booleans, String, Numeric, Array). You can add to_toml methods to your own classes to allow them to be easily serialized by the generator (and it will shout if something doesn’t have a to_toml method).
# File lib/toml/generator.rb, line 23 def self.inject! return if @@injected require 'toml/monkey_patch' @@injected = true end
# File lib/toml/generator.rb, line 6 def initialize(doc) # Ensure all the to_toml methods are injected into the base Ruby classes # used by TOML. self.class.inject! @doc = doc @body = doc.to_toml return @body end