Class: Lutaml::Model::Serializable
- Inherits:
-
Object
- Object
- Lutaml::Model::Serializable
- Extended by:
- ComparableModel::ClassMethods
- Includes:
- Serialize
- Defined in:
- lib/lutaml/model/serializable.rb
Direct Known Subclasses
Address, BenchmarkRunner::BenchItem, BenchmarkRunner::BenchRoot, BaseModel, Collection, ComparableNil, Performance::TestModels::Address, Performance::TestModels::Order, Performance::TestModels::OrderItem, Performance::TestModels::Person, Performance::TestModels::SimpleModel, Validation::Issue, Validation::LayerResult, Validation::RemediationResult, Validation::Report, Xml::Schema::Xsd::Base, Xml::Schema::Xsd::NamespaceMapping, Xml::Schema::Xsd::NamespaceUriRemapping, Xml::Schema::Xsd::SchemaLocationMapping, Xml::Schema::Xsd::SerializedSchema, Xml::Schema::Xsd::TypeIndexEntry, Xml::Schema::Xsd::TypeResolutionResult, Xml::Schema::Xsd::ValidationError, Xml::Schema::Xsd::ValidationResult, Person, PlanWalkProbe::BulkItem, PlanWalkProbe::BulkRoot
Constant Summary collapse
- INSPECT_EXCLUDED_IVARS =
Ivars that must never take part in inspect output: they either walk the whole graph (@lutaml_parent climbs to the root, and parent-child mutual recursion never terminates under the default Object#inspect) or are bulky parse bookkeeping.
%i[ @lutaml_parent @lutaml_root @lutaml_register @using_default @element_order @attribute_order @encoding ].freeze
Constants included from Serialize
Lutaml::Model::Serialize::DEFAULT_VALUE_MAP, Lutaml::Model::Serialize::GENERATOR_STATE_KEY, Lutaml::Model::Serialize::INTERNAL_ATTRIBUTES, Lutaml::Model::Serialize::LAZY_EMPTY_COLLECTION, Lutaml::Model::Serialize::LAZY_IVAR, Lutaml::Model::Serialize::NO_ARG
Constants included from Validation
Instance Attribute Summary
Attributes included from Serialize
#lutaml_parent, #lutaml_register, #lutaml_root
Class Method Summary collapse
Instance Method Summary collapse
-
#inspect ⇒ Object
Bounded, Struct-like inspect: scalars by value, collections by size, child models by class name.
Methods included from ComparableModel::ClassMethods
Methods included from Serialize
#attr_value, #attribute_exist?, #define_singleton_attribute_methods, #extract_register_id, #finalize_deserialization, included, #init_deserialization_state, #initialize, #key_exist?, #key_value, #method_missing, #prepare_instance_format_options, #pretty_print_instance_variables, register_format_mapping_method, register_from_format_method, #register_in_reference_store, register_stream_methods, register_to_format_method, #respond_to_missing?, stream_documents, #to_format, #to_yaml_hash, #using_default?, #using_default_for, #validate_attribute!, #validate_root_mapping!, #value_map, #value_set_for, #values_set_for, wrap_generator_state
Methods included from Liquefiable
Methods included from Validation
#collect_validation_errors, #element_order, #format_element_sequences, new_registry, #order_names, #validate, validate, validate!, #validate!, #validate_helper, #validate_sequence!, visiting?
Methods included from ComparableModel
#already_compared?, #attributes_hash, #calculate_hash, #comparison_key, #diff, #eql?, #hash, included, #same_as?, #same_class?
Methods included from Lutaml::Model::Serialize::Builder
#initialize, #mixed_content?, #order_tracking_enabled?, #ordered?, #record_mutation, #record_mutation_collection
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Lutaml::Model::Serialize
Class Method Details
.inspect_value(value) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/lutaml/model/serializable.rb', line 34 def inspect_value(value) case value when nil, true, false, Numeric, Symbol then value.inspect when String then value.inspect.length > 48 ? "#{value.inspect[0, 45]}...".inspect : value.inspect when Array then "(#{value.size} items)" when Hash then "{#{value.size} keys}" else "##{value.class.name}" end end |
Instance Method Details
#inspect ⇒ Object
Bounded, Struct-like inspect: scalars by value, collections by size, child models by class name. The default Object#inspect recurses through @lutaml_parent and re-enters children forever on real parsed documents.
25 26 27 28 29 30 31 |
# File 'lib/lutaml/model/serializable.rb', line 25 def inspect parts = (instance_variables - INSPECT_EXCLUDED_IVARS).map do |iv| "#{iv}=#{self.class.inspect_value(instance_variable_get(iv))}" end attrs = " #{parts.join(', ')}" unless parts.empty? "#<#{self.class.name}#{attrs}>" end |