Module: Lutaml::Uml::HasMembers

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
20
# File 'lib/lutaml/uml/has_members.rb', line 9

def members=(value) # rubocop:disable Metrics/AbcSize
  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(:"#{association_type(type)}=",
                         attribute_value.first)
      end

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