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
- #clients_dependencies ⇒ Object
- #constraints ⇒ Object
- #definition ⇒ 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
133 134 135 136 137 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 133 def associations Array(@model.associations).filter_map do |assoc| ::Lutaml::Xmi::LiquidDrops::AssociationDrop.new(assoc, @options) end end |
#attributes ⇒ Object
99 100 101 102 103 104 105 106 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 99 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 |
#clients_dependencies ⇒ Object
120 121 122 123 124 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 120 def clients_dependencies Array(@clients_dependencies).filter_map do |dependency| ::Lutaml::Xmi::LiquidDrops::DependencyDrop.new(dependency, @options) end end |
#constraints ⇒ Object
145 146 147 148 149 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 145 def constraints Array(@model.constraints).map do |constraint| ::Lutaml::Xmi::LiquidDrops::ConstraintDrop.new(constraint) end end |
#definition ⇒ Object
179 180 181 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 179 def definition @model.definition end |
#generalization ⇒ Object
151 152 153 154 155 156 157 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 151 def generalization if @options[:with_gen] && @model.generalization ::Lutaml::Xmi::LiquidDrops::GeneralizationDrop.new( @model.generalization, @klass_guidance, @options ) end end |
#has_guidance? ⇒ Boolean
171 172 173 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 171 def has_guidance? !!@klass_guidance end |
#inheritances ⇒ Object
126 127 128 129 130 131 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 126 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
175 176 177 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 175 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
139 140 141 142 143 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 139 def operations Array(@model.operations).map do |operation| ::Lutaml::Xmi::LiquidDrops::OperationDrop.new(operation) end end |
#owned_attributes ⇒ Object
108 109 110 111 112 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 108 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 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 72 def package nested_pkg = @lookup.find_packaged_element_by_id(@model.xmi_id) return unless nested_pkg xmi_pkg = nested_pkg.packaged_element&.find do |e| e.type?("uml:Package") end return unless xmi_pkg uml_pkg = ::Lutaml::Uml::Package.new uml_pkg.xmi_id = xmi_pkg.id uml_pkg.name = @lookup.get_package_name(xmi_pkg) ::Lutaml::Xmi::LiquidDrops::PackageDrop.new( uml_pkg, @guidance, @options.merge( { absolute_path: "#{@options[:absolute_path]}::#{name}", }, ), ) end |
#stereotype ⇒ Object
183 184 185 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 183 def stereotype @model.stereotype&.first end |
#subtype_of ⇒ Object
166 167 168 169 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 166 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
114 115 116 117 118 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 114 def suppliers_dependencies Array(@suppliers_dependencies).filter_map do |dependency| ::Lutaml::Xmi::LiquidDrops::DependencyDrop.new(dependency, @options) end end |
#type ⇒ Object
95 96 97 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 95 def type @model.type end |
#upper_packaged_element ⇒ Object
159 160 161 162 163 164 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 159 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 |