Class: Lutaml::Toml::Adapter::Mapping

Inherits:
KeyValue::Mapping show all
Defined in:
lib/lutaml/toml/adapter/mapping.rb

Instance Attribute Summary

Attributes inherited from KeyValue::Mapping

#format, #key_mapping, #mappings, #register_mappings, #value_mapping

Instance Method Summary collapse

Methods inherited from KeyValue::Mapping

#duplicate_mappings, #finalize, #finalized?, #find_by_name, #find_by_to, #find_by_to!, #import_model_mappings, #instance_mapping?, #map, #map_all, #map_instances, #map_key, #map_to_instance, #map_value, #mappings_hash, #name_for_mapping, #no_root, #no_root?, #polymorphic_mapping, #root, #root_mapping, #root_name, #validate_blank_mappings!, #validate_mappings!, #validate_root_mappings!, #validate_to_and_with_arguments!, #validate_with_options!

Methods inherited from Model::Mapping

#add_listener, #all_listeners, #ensure_mappings_imported!, #inherit_from, #listeners_for, #mappings, #omit_element, #omit_listener, #parent_mapping

Constructor Details

#initializeMapping

Returns a new instance of Mapping.



7
8
9
# File 'lib/lutaml/toml/adapter/mapping.rb', line 7

def initialize
  super(:toml)
end

Instance Method Details

#deep_dupObject



11
12
13
14
15
# File 'lib/lutaml/toml/adapter/mapping.rb', line 11

def deep_dup
  self.class.new.tap do |new_mapping|
    new_mapping.mappings = duplicate_mappings
  end
end

#validate!(key, to, with, render_nil, render_empty) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/lutaml/toml/adapter/mapping.rb', line 17

def validate!(key, to, with, render_nil, render_empty)
  super

  if [true, :as_nil].include?(render_nil) || render_empty == :as_nil
    raise Lutaml::Model::IncorrectMappingArgumentsError,
          "nil values are not supported in toml format"
  end
end