Class: Lutaml::KeyValue::Adapter::Toml::TomlRbAdapter
- Defined in:
- lib/lutaml/key_value/adapter/toml/toml_rb_adapter.rb
Instance Attribute Summary
Attributes inherited from Document
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Document
#[], #[]=, #initialize, #key?, #to_h
Constructor Details
This class inherits a constructor from Lutaml::KeyValue::Document
Class Method Details
.parse(toml, _options = {}) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/lutaml/key_value/adapter/toml/toml_rb_adapter.rb', line 12 def self.parse(toml, = {}) require "toml-rb" TomlRB.parse(toml) rescue LoadError raise LoadError, "toml-rb gem is not available. Please add 'toml-rb' to your Gemfile or use tomlib adapter." end |
Instance Method Details
#to_toml ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/lutaml/key_value/adapter/toml/toml_rb_adapter.rb', line 20 def to_toml(*) require "toml-rb" # Handle KeyValueElement input (new symmetric architecture) attributes_to_serialize = if @attributes.is_a?(Lutaml::KeyValue::DataModel::Element) # Unwrap __root__ wrapper to get actual content @attributes.to_hash["__root__"] else # Legacy Hash input (backward compatibility) @attributes end TomlRB.dump(attributes_to_serialize) rescue LoadError raise LoadError, "toml-rb gem is not available. Please add 'toml-rb' to your Gemfile or use tomlib adapter." end |