Flockingbird/roost

View on GitHub
app/aggregates/member/tag_list.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
# frozen_string_literal: true

module Aggregates
  class Member
    ##
    # A +TagList+ is an ordered Set. Ensuring tags with same names are merged.
    class TagList < Array
      def <<(other)
        if include?(other)
          find_original(other).merge(other)
        else
          super(other)
        end
      end

      private

      def find_original(other)
        find { |tag| tag == other }
      end
    end
  end
end