Class: Ea::Sources::Qea::StereotypeBuilder
- Inherits:
-
Object
- Object
- Ea::Sources::Qea::StereotypeBuilder
- Defined in:
- lib/ea/sources/qea/stereotype_builder.rb
Overview
Builds Ea::Model::Stereotype instances from EA's
t_stereotypes table and from the stereotype column on
individual elements. EA's stereotype storage is messy — a
stereotype can be declared globally and applied per-element
by name. We treat each distinct applied stereotype name as
an instance and reference it from the applying element.
Instance Attribute Summary collapse
-
#database ⇒ Object
readonly
Returns the value of attribute database.
Instance Method Summary collapse
- #build_all ⇒ Object
- #build_one(stereotype_row) ⇒ Object
-
#initialize(database) ⇒ StereotypeBuilder
constructor
A new instance of StereotypeBuilder.
-
#refs_for_object(object) ⇒ Object
Apply references: which stereotypes apply to a given EA object.
Constructor Details
#initialize(database) ⇒ StereotypeBuilder
Returns a new instance of StereotypeBuilder.
15 16 17 |
# File 'lib/ea/sources/qea/stereotype_builder.rb', line 15 def initialize(database) @database = database end |
Instance Attribute Details
#database ⇒ Object (readonly)
Returns the value of attribute database.
13 14 15 |
# File 'lib/ea/sources/qea/stereotype_builder.rb', line 13 def database @database end |
Instance Method Details
#build_all ⇒ Object
19 20 21 22 |
# File 'lib/ea/sources/qea/stereotype_builder.rb', line 19 def build_all stereotypes = database.collections[:stereotypes] || [] stereotypes.map { |st| build_one(st) } end |
#build_one(stereotype_row) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ea/sources/qea/stereotype_builder.rb', line 24 def build_one(stereotype_row) name = stereotype_row.stereotype Ea::Model::Stereotype.new( id: IdNormalizer.from_guid(stereotype_row.ea_guid) || IdNormalizer.synthetic("stereotype", name), name: name, qualified_name: name, profile: stereotype_row.appliesto ) end |
#refs_for_object(object) ⇒ Object
Apply references: which stereotypes apply to a given EA object.
36 37 38 39 40 |
# File 'lib/ea/sources/qea/stereotype_builder.rb', line 36 def refs_for_object(object) refs = [] refs << object.stereotype if object.stereotype && !object.stereotype.empty? refs.uniq end |