Sha256: 96e5fea42f981c3034b65bec6502eee976925c1f4034ad52a829382efd3e6d23

Contents?: true

Size: 1.35 KB

Versions: 29

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true

module Lutaml
  module Uml
    class Association < TopElement
      include HasMembers

      attr_accessor :owner_end,
                    :owner_end_attribute_name,
                    :owner_end_cardinality,
                    :owner_end_type,
                    :owner_end_xmi_id,
                    :member_end,
                    :member_end_attribute_name,
                    :member_end_xmi_id,
                    :member_end_cardinality,
                    :member_end_type,
                    :static,
                    :action

      # TODO: move to Parslet::Transform
      def members=(value)
        value.group_by { |member| member.keys.first }
          .each do |(type, group)|
            if %w[owner_end member_end].include?(type)
              group.each do |member|
                member.each_pair do |key, member_value|
                  public_send("#{associtaion_type(key)}=", member_value)
                end
              end
              next
            end
            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
    end
  end
end

Version data entries

29 entries across 29 versions & 2 rubygems

Version Path
lutaml-0.9.25 lib/lutaml/uml/association.rb
lutaml-0.9.24 lib/lutaml/uml/association.rb
lutaml-0.9.23 lib/lutaml/uml/association.rb
lutaml-0.9.22 lib/lutaml/uml/association.rb
lutaml-0.9.21 lib/lutaml/uml/association.rb
lutaml-0.9.20 lib/lutaml/uml/association.rb
lutaml-0.9.19 lib/lutaml/uml/association.rb
lutaml-0.9.18 lib/lutaml/uml/association.rb
lutaml-0.9.17 lib/lutaml/uml/association.rb
lutaml-0.9.16 lib/lutaml/uml/association.rb
lutaml-0.9.15 lib/lutaml/uml/association.rb
lutaml-0.9.14 lib/lutaml/uml/association.rb
lutaml-0.9.13 lib/lutaml/uml/association.rb
lutaml-0.9.12 lib/lutaml/uml/association.rb
lutaml-0.9.11 lib/lutaml/uml/association.rb
lutaml-0.9.10 lib/lutaml/uml/association.rb
lutaml-0.9.9 lib/lutaml/uml/association.rb
lutaml-0.9.8 lib/lutaml/uml/association.rb
lutaml-0.9.7 lib/lutaml/uml/association.rb
lutaml-0.9.6 lib/lutaml/uml/association.rb