Sha256: 9c06fb9ebe39724174d1ad2ffc5a980531ff762535f5e0bf17a3d74263ef769c
Contents?: true
Size: 823 Bytes
Versions: 46
Compression:
Stored size: 823 Bytes
Contents
# frozen_string_literal: true module Lutaml module Uml module HasMembers class UnknownMemberTypeError < StandardError; end # TODO: move to Parslet::Transform 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 private def associtaion_type(type) return type if respond_to?("#{type}=") raise(UnknownMemberTypeError, "Unknown member type: #{type}") end end end end
Version data entries
46 entries across 46 versions & 2 rubygems