Class: Lutaml::Lml::DataProcessor
- Inherits:
-
Object
- Object
- Lutaml::Lml::DataProcessor
- Includes:
- AttributeProcessing, CollectionProcessing, InstanceProcessing, ValueProcessing, ViewProcessing
- Defined in:
- lib/lutaml/lml/data_processor.rb,
lib/lutaml/lml/data_processor/view_processing.rb,
lib/lutaml/lml/data_processor/value_processing.rb,
lib/lutaml/lml/data_processor/instance_processing.rb,
lib/lutaml/lml/data_processor/attribute_processing.rb,
lib/lutaml/lml/data_processor/collection_processing.rb
Defined Under Namespace
Modules: AttributeProcessing, CollectionProcessing, InstanceProcessing, ValueProcessing, ViewProcessing
Constant Summary collapse
- KEY_HANDLERS =
{ requires: :process_requires, instances: :process_instances, instance: :process_instance, attributes: :process_attributes, show_list: :process_show_list, hide_list: :process_hide_list }.freeze
Constants included from InstanceProcessing
InstanceProcessing::INSTANCE_FIELD_HANDLERS, InstanceProcessing::INSTANCE_KEY_HANDLERS
Constants included from AttributeProcessing
AttributeProcessing::EXCLUDED_PASS_THROUGH_KEYS
Constants included from ValueProcessing
ValueProcessing::VALUE_TYPE_HANDLERS, ValueProcessing::VALUE_TYPE_KEYS
Class Method Summary collapse
Instance Method Summary collapse
Methods included from ViewProcessing
#process_hide_list, #process_show_list
Methods included from CollectionProcessing
#process_collections, #process_exports, #process_imports
Methods included from InstanceProcessing
#handle_instance_attributes, #handle_instance_nested, #handle_instance_template, #handle_instance_type, #process_instance, #process_instances
Methods included from AttributeProcessing
#process_attributes, #process_attributes_array, #process_attributes_hash
Methods included from ValueProcessing
#handle_boolean_value, #handle_delegate_value, #handle_float_value, #handle_instance_value, #handle_key_value_map, #handle_list_value, #handle_number_value, #handle_string_value, #process_array_value, #process_list_value, #process_value
Class Method Details
.process(obj) ⇒ Object
27 28 29 |
# File 'lib/lutaml/lml/data_processor.rb', line 27 def self.process(obj) new.process_data(obj) end |
Instance Method Details
#process_data(obj) ⇒ Object
31 32 33 34 35 |
# File 'lib/lutaml/lml/data_processor.rb', line 31 def process_data(obj) return obj unless obj.is_a?(Hash) || obj.is_a?(Array) obj.is_a?(Array) ? obj.map { |item| process_data(item) } : process_hash(obj) end |
#process_hash(obj) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/lutaml/lml/data_processor.rb', line 37 def process_hash(obj) obj.each_with_object({}) do |(key, value), result| handler = KEY_HANDLERS[key] result[key] = handler ? public_send(handler, value) : process_data(value) end end |
#process_requires(obj) ⇒ Object
44 45 46 |
# File 'lib/lutaml/lml/data_processor.rb', line 44 def process_requires(obj) obj.map { |req| process_value(req).last } end |