Class: Lutaml::Model::ConsolidationMap::Builder
- Inherits:
-
Object
- Object
- Lutaml::Model::ConsolidationMap::Builder
- Defined in:
- lib/lutaml/model/consolidation_map.rb
Overview
Builder evaluates the consolidate_map block
Instance Method Summary collapse
- #build ⇒ Object
-
#dispatch_by(discriminator) ⇒ Object
Pattern A: declare discriminator routing.
-
#gather(source, to:) ⇒ Object
Pattern A: gather a shared attribute from grouped instances.
-
#initialize(by, to, group_class) ⇒ Builder
constructor
A new instance of Builder.
-
#map_content(to:) ⇒ Object
Pattern B: map text content to an attribute.
-
#map_element(element_name, to:) ⇒ Object
Pattern B: map an element name to an attribute.
Constructor Details
#initialize(by, to, group_class) ⇒ Builder
Returns a new instance of Builder.
29 30 31 32 33 34 |
# File 'lib/lutaml/model/consolidation_map.rb', line 29 def initialize(by, to, group_class) @by = by @to = to @group_class = group_class @rules = [] end |
Instance Method Details
#build ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'lib/lutaml/model/consolidation_map.rb', line 57 def build ConsolidationMap.new( by: @by, to: @to, group_class: @group_class, rules: @rules, ) end |
#dispatch_by(discriminator) ⇒ Object
Pattern A: declare discriminator routing
42 43 44 45 |
# File 'lib/lutaml/model/consolidation_map.rb', line 42 def dispatch_by(discriminator, &) routes = DispatchBuilder.new.evaluate(&) @rules << DispatchBlock.new(discriminator, routes) end |
#gather(source, to:) ⇒ Object
Pattern A: gather a shared attribute from grouped instances
37 38 39 |
# File 'lib/lutaml/model/consolidation_map.rb', line 37 def gather(source, to:) @rules << GatherRule.new(source, to) end |
#map_content(to:) ⇒ Object
Pattern B: map text content to an attribute
53 54 55 |
# File 'lib/lutaml/model/consolidation_map.rb', line 53 def map_content(to:) @rules << PatternContentRule.new(to) end |
#map_element(element_name, to:) ⇒ Object
Pattern B: map an element name to an attribute
48 49 50 |
# File 'lib/lutaml/model/consolidation_map.rb', line 48 def map_element(element_name, to:) @rules << PatternElementRule.new(element_name, to) end |