Class: TOML::Generator
Constant Summary collapse
- @@injected =
Whether or not the injections have already been done.
false
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#doc ⇒ Object
readonly
Returns the value of attribute doc.
Class Method Summary collapse
-
.inject! ⇒ Object
Inject to_toml methods into the Ruby classes used by TOML (booleans, String, Numeric, Array).
Instance Method Summary collapse
-
#initialize(doc) ⇒ Generator
constructor
A new instance of Generator.
Constructor Details
#initialize(doc) ⇒ Generator
Returns a new instance of Generator.
6 7 8 9 10 11 12 13 14 15 |
# 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 |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
4 5 6 |
# File 'lib/toml/generator.rb', line 4 def body @body end |
#doc ⇒ Object (readonly)
Returns the value of attribute doc.
4 5 6 |
# File 'lib/toml/generator.rb', line 4 def doc @doc end |
Class Method Details
.inject! ⇒ Object
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).
23 24 25 26 27 |
# File 'lib/toml/generator.rb', line 23 def self.inject! return if @@injected require 'toml/monkey_patch' @@injected = true end |