Sha256: cd9264bb81cb183335f3363dcb70a1ed00560950e73e4b5950dc52d0a6588dc7

Contents?: true

Size: 1.27 KB

Versions: 17

Compression:

Stored size: 1.27 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,
                    :member_end,
                    :member_end_attribute_name,
                    :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

17 entries across 17 versions & 1 rubygems

Version Path
lutaml-uml-0.4.1 lib/lutaml/uml/association.rb
lutaml-uml-0.4.0 lib/lutaml/uml/association.rb
lutaml-uml-0.3.2 lib/lutaml/uml/association.rb
lutaml-uml-0.3.1 lib/lutaml/uml/association.rb
lutaml-uml-0.3.0 lib/lutaml/uml/association.rb
lutaml-uml-0.2.12 lib/lutaml/uml/association.rb
lutaml-uml-0.2.10 lib/lutaml/uml/association.rb
lutaml-uml-0.2.9 lib/lutaml/uml/association.rb
lutaml-uml-0.2.8 lib/lutaml/uml/association.rb
lutaml-uml-0.2.7 lib/lutaml/uml/association.rb
lutaml-uml-0.2.6 lib/lutaml/uml/association.rb
lutaml-uml-0.2.5 lib/lutaml/uml/association.rb
lutaml-uml-0.2.4 lib/lutaml/uml/association.rb
lutaml-uml-0.2.3 lib/lutaml/uml/association.rb
lutaml-uml-0.2.2 lib/lutaml/uml/association.rb
lutaml-uml-0.2.1 lib/lutaml/uml/association.rb
lutaml-uml-0.2.0 lib/lutaml/uml/association.rb