Class: Ea::Sources::Qea::PropertyBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/ea/sources/qea/property_builder.rb

Overview

Translates EA t_attribute rows into Ea::Model::Property instances. Multiplicity is parsed from EA's LowerBound / UpperBound columns (with * represented as -1 in the model).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(database) ⇒ PropertyBuilder

Returns a new instance of PropertyBuilder.



13
14
15
# File 'lib/ea/sources/qea/property_builder.rb', line 13

def initialize(database)
  @database = database
end

Instance Attribute Details

#databaseObject (readonly)

Returns the value of attribute database.



11
12
13
# File 'lib/ea/sources/qea/property_builder.rb', line 11

def database
  @database
end

Instance Method Details

#build_all_for(owner_object) ⇒ Object



17
18
19
20
# File 'lib/ea/sources/qea/property_builder.rb', line 17

def build_all_for(owner_object)
  attrs = database.attributes_for_object(owner_object.ea_object_id) || []
  attrs.map { |row| build_one(row, owner_object) }
end

#build_one(row, owner_object) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/ea/sources/qea/property_builder.rb', line 22

def build_one(row, owner_object)
  Ea::Model::Property.new(
    id: IdNormalizer.from_guid(row.ea_guid),
    name: row.name,
    owner_id: IdNormalizer.from_guid(owner_object.ea_guid),
    type_name: row.type,
    qualified_name: "#{owner_object.name}::#{row.name}",
    multiplicity_lower: parse_lower(row),
    multiplicity_upper: parse_upper(row),
    default_value: row.default,
    is_ordered: boolean(row.isordered),
    is_unique: !boolean(row.allowduplicates),
    visibility: visibility_from_scope(row.scope),
    aggregation: "none",
    stereotype_refs: stereotype_refs(row),
    tagged_values: TaggedValueBuilder.new(database).for_attribute(row),
    annotations: AnnotationBuilder.from_note(row.notes, row.ea_guid,
                                             kind: "documentation")
  )
end