Module: Lutaml::Model::RenderPolicy
- Included in:
- KeyValue::Transformation, KeyValue::Transformation::CollectionSerializer, KeyValue::Transformation::ValueSerializer, Xml::TransformationSupport::SkipLogic
- Defined in:
- lib/lutaml/model/render_policy.rb
Overview
Shared render policy mixin for determining what values to skip/render.
Used by both Xml::Transformation and KeyValue::Transformation to provide consistent behavior across serialization formats.
All render/skip decisions are made through the value_map, which is the single source of truth. The user-facing render_nil/render_empty DSL options are normalized into value_map entries at MappingRule construction time, so downstream code never needs to re-interpret them.
Class Method Summary collapse
Instance Method Summary collapse
-
#should_skip_delegated_value?(value, rule, delegate_obj) ⇒ Boolean
Check if delegated value should be skipped.
-
#should_skip_value?(value, rule, model_instance) ⇒ Boolean
Check if value should be skipped based on render options.
Class Method Details
.derived_attribute_for?(context_obj, attr_name) ⇒ Boolean
15 16 17 18 19 20 21 22 |
# File 'lib/lutaml/model/render_policy.rb', line 15 def self.derived_attribute_for?(context_obj, attr_name) return false unless context_obj.is_a?(Lutaml::Model::Serialize) && context_obj.class.is_a?(Class) && context_obj.class.include?(Lutaml::Model::Serialize) register = context_obj.lutaml_register context_obj.class.attributes(register)&.[](attr_name)&.derived? end |
Instance Method Details
#should_skip_delegated_value?(value, rule, delegate_obj) ⇒ Boolean
Check if delegated value should be skipped
40 41 42 43 44 |
# File 'lib/lutaml/model/render_policy.rb', line 40 def should_skip_delegated_value?(value, rule, delegate_obj) return true if delegate_obj.nil? check_skip_logic?(value, rule, delegate_obj) end |
#should_skip_value?(value, rule, model_instance) ⇒ Boolean
Check if value should be skipped based on render options
30 31 32 |
# File 'lib/lutaml/model/render_policy.rb', line 30 def should_skip_value?(value, rule, model_instance) check_skip_logic?(value, rule, model_instance) end |