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, guidance = nil) ⇒ 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, guidance = nil) ⇒ GeneralizationDrop
rubocop:disable Lint/MissingSuper
6 7 8 9 10 11 12 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 6 def initialize(gen, guidance = nil) # rubocop:disable Lint/MissingSuper @gen = gen @looped_general_item = false @inherited_props = [] @inherited_assoc_props = [] @guidance = guidance end |
Instance Method Details
#assoc_props ⇒ 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 attributes.select do |attr| attr[:association] end.map do |attr| GeneralizationAttributeDrop.new(attr, upper_klass, name, @guidance) end end |
#attributes ⇒ Object
34 35 36 37 38 39 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 34 def attributes @gen[:general_attributes] # @gen[:general_attributes].map do |attr| # GeneralizationAttributeDrop.new(attr, upper_klass, name) # end end |
#definition ⇒ Object
45 46 47 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 45 def definition @gen[:definition] end |
#general ⇒ Object
26 27 28 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 26 def general GeneralizationDrop.new(@gen[:general], @guidance) if @gen[:general] end |
#has_general? ⇒ Boolean
30 31 32 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 30 def has_general? !!@gen[:general] end |
#id ⇒ Object
14 15 16 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 14 def id @gen[:general_id] end |
#inherited_assoc_props ⇒ Object
get items with association by looping through the generation
79 80 81 82 83 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 79 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
72 73 74 75 76 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 72 def inherited_props loop_general_item unless @looped_general_item @inherited_props.reverse end |
#loop_general_item ⇒ Object
rubocop:disable Metrics/MethodLength
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 85 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, @guidance) 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
18 19 20 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 18 def name @gen[:general_name] end |
#owned_props ⇒ 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 attributes.select do |attr| attr[:association].nil? end.map do |attr| GeneralizationAttributeDrop.new(attr, upper_klass, name, @guidance) end 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
22 23 24 |
# File 'lib/lutaml/xmi/liquid_drops/generalization_drop.rb', line 22 def upper_klass @gen[:general_upper_klass] end |