Class: Lutaml::Xmi::LiquidDrops::KlassDrop
- Inherits:
-
Liquid::Drop
- Object
- Liquid::Drop
- Lutaml::Xmi::LiquidDrops::KlassDrop
- Defined in:
- lib/lutaml/xmi/liquid_drops/klass_drop.rb
Instance Method Summary collapse
- #absolute_path ⇒ Object
- #associations ⇒ Object
- #attributes ⇒ Object
- #build_uml_package(xmi_pkg) ⇒ Object
- #clients_dependencies ⇒ Object
- #constraints ⇒ Object
- #definition ⇒ Object
- #find_nested_xmi_package ⇒ Object
- #generalization ⇒ Object
- #has_guidance? ⇒ Boolean
- #inheritances ⇒ Object
-
#initialize(model, guidance = nil, options = {}) ⇒ KlassDrop
constructor
rubocop:disable Lint/MissingSuper.
-
#is_abstract ⇒ Object
rubocop:disable Naming/PredicateName,Naming/PredicatePrefix.
- #name ⇒ Object
- #operations ⇒ Object
- #owned_attributes ⇒ Object
- #package ⇒ Object
- #stereotype ⇒ Object
- #subtype_of ⇒ Object
- #suppliers_dependencies ⇒ Object
- #type ⇒ Object
- #upper_packaged_element ⇒ Object
- #xmi_id ⇒ Object
Constructor Details
#initialize(model, guidance = nil, options = {}) ⇒ KlassDrop
rubocop:disable Lint/MissingSuper
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 7 def initialize(model, guidance = nil, = {}) # rubocop:disable Lint/MissingSuper @model = model @guidance = guidance @options = @lookup = [:lookup] @xmi_root_model = [:xmi_root_model] @id_name_mapping = [:id_name_mapping] init_xmi_dependencies if @xmi_root_model init_guidance(guidance) if guidance end |
Instance Method Details
#absolute_path ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 27 def absolute_path absolute_path_arr = [@model.name] e = @lookup.find_upper_level_packaged_element(@model.xmi_id) absolute_path_arr << e.name if e while e e = @lookup.find_upper_level_packaged_element(e.id) absolute_path_arr << e.name if e end absolute_path_arr << "::#{@xmi_root_model.model.name}" absolute_path_arr.reverse.join("::") end |
#associations ⇒ Object
135 136 137 138 139 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 135 def associations Array(@model.associations).filter_map do |assoc| ::Lutaml::Xmi::LiquidDrops::AssociationDrop.new(assoc, @options) end end |
#attributes ⇒ Object
101 102 103 104 105 106 107 108 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 101 def attributes Array(@model.attributes).filter_map do |owned_attr| if @options[:with_assoc] || owned_attr.association.nil? ::Lutaml::Xmi::LiquidDrops::AttributeDrop.new(owned_attr, @options) end end end |
#build_uml_package(xmi_pkg) ⇒ Object
90 91 92 93 94 95 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 90 def build_uml_package(xmi_pkg) uml_pkg = ::Lutaml::Uml::Package.new uml_pkg.xmi_id = xmi_pkg.id uml_pkg.name = @lookup.get_package_name(xmi_pkg) uml_pkg end |
#clients_dependencies ⇒ Object
122 123 124 125 126 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 122 def clients_dependencies Array(@clients_dependencies).filter_map do |dependency| ::Lutaml::Xmi::LiquidDrops::DependencyDrop.new(dependency, @options) end end |
#constraints ⇒ Object
147 148 149 150 151 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 147 def constraints Array(@model.constraints).map do |constraint| ::Lutaml::Xmi::LiquidDrops::ConstraintDrop.new(constraint) end end |
#definition ⇒ Object
181 182 183 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 181 def definition @model.definition end |
#find_nested_xmi_package ⇒ Object
83 84 85 86 87 88 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 83 def find_nested_xmi_package nested_pkg = @lookup.find_packaged_element_by_id(@model.xmi_id) return unless nested_pkg nested_pkg.packaged_element&.find { |e| e.type?("uml:Package") } end |
#generalization ⇒ Object
153 154 155 156 157 158 159 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 153 def generalization if @options[:with_gen] && @model.generalization ::Lutaml::Xmi::LiquidDrops::GeneralizationDrop.new( @model.generalization, @klass_guidance, @options ) end end |
#has_guidance? ⇒ Boolean
173 174 175 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 173 def has_guidance? !!@klass_guidance end |
#inheritances ⇒ Object
128 129 130 131 132 133 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 128 def inheritances Array(@inheritance_ids).filter_map do |inheritance_id| connector = @lookup.fetch_connector(inheritance_id) ::Lutaml::Xmi::LiquidDrops::ConnectorDrop.new(connector, @options) end end |
#is_abstract ⇒ Object
rubocop:disable Naming/PredicateName,Naming/PredicatePrefix
177 178 179 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 177 def is_abstract # rubocop:disable Naming/PredicateName,Naming/PredicatePrefix @model.is_abstract end |
#name ⇒ Object
23 24 25 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 23 def name @model.name end |
#operations ⇒ Object
141 142 143 144 145 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 141 def operations Array(@model.operations).map do |operation| ::Lutaml::Xmi::LiquidDrops::OperationDrop.new(operation) end end |
#owned_attributes ⇒ Object
110 111 112 113 114 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 110 def owned_attributes Array(@model.attributes).filter_map do |owned_attr| ::Lutaml::Xmi::LiquidDrops::AttributeDrop.new(owned_attr, @options) end end |
#package ⇒ Object
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 72 def package xmi_pkg = find_nested_xmi_package return unless xmi_pkg ::Lutaml::Xmi::LiquidDrops::PackageDrop.new( build_uml_package(xmi_pkg), @guidance, @options.merge(absolute_path: "#{@options[:absolute_path]}::#{name}"), ) end |
#stereotype ⇒ Object
185 186 187 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 185 def stereotype @model.stereotype&.first end |
#subtype_of ⇒ Object
168 169 170 171 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 168 def subtype_of @lookup.find_subtype_of_from_generalization(@model.xmi_id) || @lookup.find_subtype_of_from_owned_attribute_type(@model.xmi_id) end |
#suppliers_dependencies ⇒ Object
116 117 118 119 120 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 116 def suppliers_dependencies Array(@suppliers_dependencies).filter_map do |dependency| ::Lutaml::Xmi::LiquidDrops::DependencyDrop.new(dependency, @options) end end |
#type ⇒ Object
97 98 99 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 97 def type @model.type end |
#upper_packaged_element ⇒ Object
161 162 163 164 165 166 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 161 def upper_packaged_element if @options[:with_gen] e = @lookup.find_upper_level_packaged_element(@model.xmi_id) e&.name end end |
#xmi_id ⇒ Object
19 20 21 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 19 def xmi_id @model.xmi_id end |