Class: Ea::Sources::Xmi::ClassifierBuilder
- Inherits:
-
Object
- Object
- Ea::Sources::Xmi::ClassifierBuilder
- Defined in:
- lib/ea/sources/xmi/classifier_builder.rb
Overview
Translates XMI classifier elements (uml:Class, uml:DataType, uml:Enumeration, uml:Interface, uml:PrimitiveType) into the appropriate Ea::Model::Classifier subclass. Uses TypeClassifierMap for dispatch (OCP).
Instance Attribute Summary collapse
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #build_all ⇒ Object
- #build_one(element, containing_package) ⇒ Object
-
#initialize(root) ⇒ ClassifierBuilder
constructor
A new instance of ClassifierBuilder.
Constructor Details
#initialize(root) ⇒ ClassifierBuilder
Returns a new instance of ClassifierBuilder.
13 14 15 |
# File 'lib/ea/sources/xmi/classifier_builder.rb', line 13 def initialize(root) @root = root end |
Instance Attribute Details
#root ⇒ Object (readonly)
Returns the value of attribute root.
11 12 13 |
# File 'lib/ea/sources/xmi/classifier_builder.rb', line 11 def root @root end |
Instance Method Details
#build_all ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/ea/sources/xmi/classifier_builder.rb', line 17 def build_all classifiers = [] walk(root.model) do |element, parent_pkg| next unless TypeClassifierMap.classifier_type?(element.type) classifiers << build_one(element, parent_pkg) end classifiers end |
#build_one(element, containing_package) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/ea/sources/xmi/classifier_builder.rb', line 27 def build_one(element, containing_package) klass = TypeClassifierMap.class_for(element.type) args = common_args(element, containing_package) args.merge!(enumeration_args(element)) if klass == Ea::Model::Enumeration klass.new(**args) end |