Module: Lutaml::Uml::HasMembers

Included in:
Association, Class, DataType, Document, Enum, Operation, TopElementAttribute, Value
Defined in:
lib/lutaml/uml/has_members.rb

Defined Under Namespace

Classes: UnknownMemberTypeError

Instance Method Summary collapse

Instance Method Details

#members=(value) ⇒ Object

TODO: move to Parslet::Transform



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/lutaml/uml/has_members.rb', line 9

def members=(value)
  value.group_by { |member| member.keys.first }
    .each do |(type, group)|
      attribute_value = group.map(&:values).flatten
      if attribute_value.length == 1 && !attribute_value.first.is_a?(Hash)
        next public_send("#{associtaion_type(type)}=", attribute_value.first)
      end

      public_send("#{associtaion_type(type)}=", attribute_value)
    end
end