Class: Lutaml::Xmi::LiquidDrops::GeneralizationDrop
- Inherits:
-
Liquid::Drop
- Object
- Liquid::Drop
- Lutaml::Xmi::LiquidDrops::GeneralizationDrop
- Defined in:
- lib/lutaml/xmi/liquid_drops/generalization_drop.rb
Instance Method Summary collapse
-
#assoc_props(sort: false) ⇒ Object
get attributes with association.
- #attributes ⇒ Object
- #definition ⇒ Object
- #general ⇒ Object
- #has_general? ⇒ Boolean
- #id ⇒ Object
-
#inherited_assoc_props(sort: false) ⇒ Object
get items with association by looping through the generation.
-
#inherited_props(sort: false) ⇒ Object
get items without association by looping through the generation.
-
#initialize(gen, guidance = nil, options = {}) ⇒ GeneralizationDrop
constructor
rubocop:disable Lint/MissingSuper.
- #name ⇒ Object
-
#owned_props(sort: false) ⇒ Object
get attributes without association.
- #props_to_liquid(props) ⇒ Object
- #sort_props(arr) ⇒ Object
- #sort_props_with_level(arr) ⇒ Object
- #sorted_assoc_props ⇒ Object
- #sorted_inherited_assoc_props ⇒ Object
- #sorted_inherited_props ⇒ Object
- #sorted_owned_props ⇒ Object
- #stereotype ⇒ Object
- #type ⇒ Object
- #upper_klass ⇒ Object
Constructor Details
#initialize(gen, guidance = nil, options = {}) ⇒ GeneralizationDrop
rubocop:disable Lint/MissingSuper
7 8 9 10 11 12 13 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 7 def initialize(gen, guidance = nil, = {}) # rubocop:disable Lint/MissingSuper @gen = gen @guidance = guidance @options = @xmi_root_model = [:xmi_root_model] @id_name_mapping = [:id_name_mapping] end |
Instance Method Details
#assoc_props(sort: false) ⇒ Object
get attributes with association
63 64 65 66 67 68 69 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 63 def assoc_props(sort: false) return [] unless @gen.assoc_props props = @gen.assoc_props props = sort_props(props) if sort props_to_liquid(props) end |
#attributes ⇒ Object
37 38 39 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 37 def attributes @gen.general_attributes end |
#definition ⇒ Object
45 46 47 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 45 def definition @gen.definition end |
#general ⇒ Object
27 28 29 30 31 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 27 def general if @gen.general GeneralizationDrop.new(@gen.general, @guidance, @options) end end |
#has_general? ⇒ Boolean
33 34 35 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 33 def has_general? !@gen.general.nil? end |
#id ⇒ Object
15 16 17 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 15 def id @gen.general_id end |
#inherited_assoc_props(sort: false) ⇒ Object
get items with association by looping through the generation
88 89 90 91 92 93 94 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 88 def inherited_assoc_props(sort: false) return [] unless @gen.inherited_assoc_props props = @gen.inherited_assoc_props props = sort_props_with_level(props) if sort props_to_liquid(props) end |
#inherited_props(sort: false) ⇒ Object
get items without association by looping through the generation
79 80 81 82 83 84 85 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 79 def inherited_props(sort: false) return [] unless @gen.inherited_props props = @gen.inherited_props props = sort_props_with_level(props) if sort props_to_liquid(props) end |
#name ⇒ Object
19 20 21 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 19 def name @gen.general_name end |
#owned_props(sort: false) ⇒ Object
get attributes without association
54 55 56 57 58 59 60 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 54 def owned_props(sort: false) return [] unless @gen.owned_props props = @gen.owned_props props = sort_props(props) if sort props_to_liquid(props) end |
#props_to_liquid(props) ⇒ Object
71 72 73 74 75 76 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 71 def props_to_liquid(props) props.map do |attr| GeneralizationAttributeDrop.new(attr, attr.upper_klass, attr.gen_name, @guidance) end end |
#sort_props(arr) ⇒ Object
119 120 121 122 123 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 119 def sort_props(arr) return [] if arr.nil? || arr.empty? arr.sort_by { |i| [i.name_ns.to_s, i.name.to_s] } end |
#sort_props_with_level(arr) ⇒ Object
96 97 98 99 100 101 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 96 def sort_props_with_level(arr) return [] if arr.nil? || arr.empty? # level desc, name_ns asc, name asc arr.sort_by { |i| [-i.level, i.name_ns.to_s, i.name.to_s] } end |
#sorted_assoc_props ⇒ Object
107 108 109 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 107 def sorted_assoc_props assoc_props(sort: true) end |
#sorted_inherited_assoc_props ⇒ Object
115 116 117 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 115 def sorted_inherited_assoc_props inherited_assoc_props(sort: true) end |
#sorted_inherited_props ⇒ Object
111 112 113 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 111 def sorted_inherited_props inherited_props(sort: true) end |
#sorted_owned_props ⇒ Object
103 104 105 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 103 def sorted_owned_props owned_props(sort: true) end |
#stereotype ⇒ Object
49 50 51 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 49 def stereotype @gen.stereotype end |
#type ⇒ Object
41 42 43 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 41 def type @gen.type end |
#upper_klass ⇒ Object
23 24 25 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 23 def upper_klass @gen.general_upper_klass end |