Class: Lutaml::XMI::PackageDrop

Inherits:
Liquid::Drop
  • Object
show all
Includes:
Lutaml::XMI::Parsers::XMIBase
Defined in:
lib/lutaml/xmi/liquid_drops/package_drop.rb

Instance Method Summary collapse

Methods included from Lutaml::XMI::Parsers::XMIBase

included, #set_xmi_model

Constructor Details

#initialize(model, guidance = nil, options = {}) ⇒ PackageDrop

rubocop:disable Lint/MissingSuper,Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/lutaml/xmi/liquid_drops/package_drop.rb', line 8

def initialize(model, guidance = nil, options = {}) # rubocop:disable Lint/MissingSuper,Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
  @model = model
  @guidance = guidance

  @options = options
  @xmi_root_model = options[:xmi_root_model]
  @xmi_cache = options[:xmi_cache]

  @packages = model.packaged_element.select do |e|
    e.type?("uml:Package")
  end

  @klasses = model.packaged_element.select do |e|
    e.type?("uml:Class") || e.type?("uml:AssociationClass") ||
      e.type?("uml:Interface")
  end

  @all_data_type_elements = []
  select_all_packaged_elements(@all_data_type_elements, model,
                               "uml:DataType")

  @children_packages ||= packages.map do |pkg|
    [pkg, pkg.packages, pkg.packages.map(&:children_packages)]
  end.flatten.uniq
end

Instance Method Details

#absolute_pathObject



42
43
44
# File 'lib/lutaml/xmi/liquid_drops/package_drop.rb', line 42

def absolute_path
  "#{@options[:absolute_path]}::#{name}"
end

#children_packagesObject



101
102
103
# File 'lib/lutaml/xmi/liquid_drops/package_drop.rb', line 101

def children_packages
  @children_packages
end

#data_typesObject



71
72
73
74
75
# File 'lib/lutaml/xmi/liquid_drops/package_drop.rb', line 71

def data_types
  @all_data_type_elements.map do |data_type|
    ::Lutaml::XMI::DataTypeDrop.new(data_type, @options)
  end
end

#definitionObject



105
106
107
# File 'lib/lutaml/xmi/liquid_drops/package_drop.rb', line 105

def definition
  doc_node_attribute_value(@model.id, "documentation")
end

#diagramsObject



77
78
79
80
81
82
83
84
85
# File 'lib/lutaml/xmi/liquid_drops/package_drop.rb', line 77

def diagrams
  diagrams = @xmi_root_model.extension.diagrams.diagram.select do |d|
    d.model.package == @model.id
  end

  diagrams.map do |diagram|
    ::Lutaml::XMI::DiagramDrop.new(diagram, @options)
  end
end

#enumsObject



61
62
63
64
65
66
67
68
69
# File 'lib/lutaml/xmi/liquid_drops/package_drop.rb', line 61

def enums
  enums = @model.packaged_element.select do |e|
    e.type?("uml:Enumeration")
  end

  enums.map do |enum|
    ::Lutaml::XMI::EnumDrop.new(enum, @options)
  end
end

#klassesObject Also known as: classes

rubocop:disable Metrics/MethodLength



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/lutaml/xmi/liquid_drops/package_drop.rb', line 46

def klasses # rubocop:disable Metrics/MethodLength
  @klasses.map do |klass|
    ::Lutaml::XMI::KlassDrop.new(
      klass,
      @guidance,
      @options.merge(
        {
          absolute_path: "#{@options[:absolute_path]}::#{name}",
        },
      ),
    )
  end
end

#nameObject



38
39
40
# File 'lib/lutaml/xmi/liquid_drops/package_drop.rb', line 38

def name
  get_package_name(@model)
end

#packagesObject

rubocop:disable Metrics/MethodLength



87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/lutaml/xmi/liquid_drops/package_drop.rb', line 87

def packages # rubocop:disable Metrics/MethodLength
  @packages.map do |package|
    ::Lutaml::XMI::PackageDrop.new(
      package,
      @guidance,
      @options.merge(
        {
          absolute_path: "#{@options[:absolute_path]}::#{name}",
        },
      ),
    )
  end
end

#stereotypeObject



109
110
111
# File 'lib/lutaml/xmi/liquid_drops/package_drop.rb', line 109

def stereotype
  doc_node_attribute_value(@model.id, "stereotype")
end

#xmi_idObject



34
35
36
# File 'lib/lutaml/xmi/liquid_drops/package_drop.rb', line 34

def xmi_id
  @model.id
end