Class: Lutaml::XMI::GeneralizationDrop
- Inherits:
-
Liquid::Drop
- Object
- Liquid::Drop
- Lutaml::XMI::GeneralizationDrop
- Defined in:
- lib/lutaml/xmi/liquid_drops/generalization_drop.rb
Instance Method Summary collapse
-
#assoc_props ⇒ Object
get attributes with association.
- #attributes ⇒ Object
- #definition ⇒ Object
- #general ⇒ Object
- #has_general? ⇒ Boolean
- #id ⇒ Object
-
#inherited_assoc_props ⇒ Object
get items with association by looping through the generation.
-
#inherited_props ⇒ Object
get items without association by looping through the generation.
-
#initialize(gen) ⇒ GeneralizationDrop
constructor
rubocop:disable Lint/MissingSuper.
-
#loop_general_item ⇒ Object
rubocop:disable Metrics/MethodLength.
- #name ⇒ Object
-
#owned_props ⇒ Object
get attributes without association.
- #stereotype ⇒ Object
- #type ⇒ Object
- #upper_klass ⇒ Object
Constructor Details
#initialize(gen) ⇒ GeneralizationDrop
rubocop:disable Lint/MissingSuper
6 7 8 9 10 11 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 6 def initialize(gen) # rubocop:disable Lint/MissingSuper @gen = gen @looped_general_item = false @inherited_props = [] @inherited_assoc_props = [] end |
Instance Method Details
#assoc_props ⇒ Object
get attributes with association
62 63 64 65 66 67 68 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 62 def assoc_props attributes.select do |attr| attr[:association] end.map do |attr| GeneralizationAttributeDrop.new(attr, upper_klass, name) end end |
#attributes ⇒ Object
33 34 35 36 37 38 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 33 def attributes @gen[:general_attributes] # @gen[:general_attributes].map do |attr| # GeneralizationAttributeDrop.new(attr, upper_klass, name) # end end |
#definition ⇒ Object
44 45 46 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 44 def definition @gen[:definition] end |
#general ⇒ Object
25 26 27 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 25 def general GeneralizationDrop.new(@gen[:general]) if @gen[:general] end |
#has_general? ⇒ Boolean
29 30 31 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 29 def has_general? !!@gen[:general] end |
#id ⇒ Object
13 14 15 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 13 def id @gen[:general_id] end |
#inherited_assoc_props ⇒ Object
get items with association by looping through the generation
78 79 80 81 82 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 78 def inherited_assoc_props loop_general_item unless @looped_general_item @inherited_assoc_props.reverse end |
#inherited_props ⇒ Object
get items without association by looping through the generation
71 72 73 74 75 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 71 def inherited_props loop_general_item unless @looped_general_item @inherited_props.reverse end |
#loop_general_item ⇒ Object
rubocop:disable Metrics/MethodLength
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 84 def loop_general_item # rubocop:disable Metrics/MethodLength general_item = general while general_item.has_general? gen_upper_klass = general_item.upper_klass gen_name = general_item.name # reverse the order to show super class first general_item.attributes.reverse_each do |attr| attr_drop = GeneralizationAttributeDrop.new(attr, gen_upper_klass, gen_name) if attr[:association] @inherited_assoc_props << attr_drop else @inherited_props << attr_drop end end general_item = general_item.general end @looped_general_item = true end |
#name ⇒ Object
17 18 19 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 17 def name @gen[:general_name] end |
#owned_props ⇒ Object
get attributes without association
53 54 55 56 57 58 59 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 53 def owned_props attributes.select do |attr| attr[:association].nil? end.map do |attr| GeneralizationAttributeDrop.new(attr, upper_klass, name) end end |
#stereotype ⇒ Object
48 49 50 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 48 def stereotype @gen[:stereotype] end |
#type ⇒ Object
40 41 42 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 40 def type @gen[:type] end |
#upper_klass ⇒ Object
21 22 23 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 21 def upper_klass @gen[:general_upper_klass] end |