Class: Ea::Sources::Qea::PackageBuilder
- Inherits:
-
Object
- Object
- Ea::Sources::Qea::PackageBuilder
- Defined in:
- lib/ea/sources/qea/package_builder.rb
Overview
Translates EA t_package rows into Ea::Model::Package instances. References to parent and child packages are by model id (normalized GUID), not by EA's integer Package_ID.
Instance Attribute Summary collapse
-
#database ⇒ Object
readonly
Returns the value of attribute database.
Instance Method Summary collapse
- #build_all ⇒ Object
- #build_one(pkg) ⇒ Object
-
#initialize(database) ⇒ PackageBuilder
constructor
A new instance of PackageBuilder.
Constructor Details
#initialize(database) ⇒ PackageBuilder
Returns a new instance of PackageBuilder.
12 13 14 |
# File 'lib/ea/sources/qea/package_builder.rb', line 12 def initialize(database) @database = database end |
Instance Attribute Details
#database ⇒ Object (readonly)
Returns the value of attribute database.
10 11 12 |
# File 'lib/ea/sources/qea/package_builder.rb', line 10 def database @database end |
Instance Method Details
#build_all ⇒ Object
16 17 18 19 |
# File 'lib/ea/sources/qea/package_builder.rb', line 16 def build_all packages = database.collections[:packages] || [] packages.map { |pkg| build_one(pkg) } end |
#build_one(pkg) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/ea/sources/qea/package_builder.rb', line 21 def build_one(pkg) Ea::Model::Package.new( id: IdNormalizer.from_guid(pkg.ea_guid), name: pkg.name, parent_id: parent_id_for(pkg), qualified_name: pkg.xmlpath, annotations: AnnotationBuilder.from_note(pkg.notes, pkg.ea_guid) ) end |