Module: Lutaml::Model::Config

Extended by:
Config
Included in:
Config
Defined in:
lib/lutaml/model/config.rb

Constant Summary collapse

AVAILABLE_FORMATS =
i[xml json yaml toml hash].freeze
KEY_VALUE_FORMATS =
AVAILABLE_FORMATS - i[xml]

Instance Method Summary collapse

Instance Method Details

#adapter_for(format) ⇒ Object



57
58
59
# File 'lib/lutaml/model/config.rb', line 57

def adapter_for(format)
  public_send(:"#{format}_adapter")
end

#class_for(adapter, type) ⇒ Object



73
74
75
76
# File 'lib/lutaml/model/config.rb', line 73

def class_for(adapter, type)
  Lutaml::Model.const_get(to_class_name(adapter))
    .const_get(to_class_name(type))
end

#configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



9
10
11
# File 'lib/lutaml/model/config.rb', line 9

def configure
  yield self
end

#mappings_class_for(format) ⇒ Object



65
66
67
# File 'lib/lutaml/model/config.rb', line 65

def mappings_class_for(format)
  Lutaml::Model::FormatRegistry.mappings_class_for(format)
end

#set_adapter_for(format, adapter) ⇒ Object



61
62
63
# File 'lib/lutaml/model/config.rb', line 61

def set_adapter_for(format, adapter)
  public_send(:"#{format}_adapter=", adapter)
end

#to_class_name(str) ⇒ Object



78
79
80
# File 'lib/lutaml/model/config.rb', line 78

def to_class_name(str)
  str.to_s.split("_").map(&:capitalize).join
end

#transformer_for(format) ⇒ Object



69
70
71
# File 'lib/lutaml/model/config.rb', line 69

def transformer_for(format)
  Lutaml::Model::FormatRegistry.transformer_for(format)
end