def merge!(other)
      ATTRIBUTES.each do |getter|
        already_set =
          begin
            self.send(getter)
          rescue
            false
          end
        unless already_set
          setter = :"#{getter}="
          value =
            begin
              other.send(getter)
            rescue
              nil # skip inaccessible attributes
            end
          self.send setter, value
        end
      end

      self.default_portal ||= other.default_portal
      self.portals |= other.portals
      other.all_group_memberships.keys.each do |other_portal|
        if self.group_memberships(other_portal).empty?
          self.group_memberships(other_portal).concat(other.group_memberships(other_portal))
        end
      end
      other.identifiers.each do |ident, value|
        identifiers[ident] ||= value
      end

      self
    end
def merge!(other)
      ATTRIBUTES.each do |getter|
        already_set =
          begin
            self.send(getter)
          rescue
            false
          end
        unless already_set
          setter = :"#{getter}="
          value =
            begin
              other.send(getter)
            rescue
              nil # skip inaccessible attributes
            end
          self.send setter, value
        end
      end

      self.default_portal ||= other.default_portal
      self.portals |= other.portals
      other.all_group_memberships.keys.each do |other_portal|
        if self.group_memberships(other_portal).empty?
          self.group_memberships(other_portal).concat(other.group_memberships(other_portal))
        end
      end
      other.identifiers.each do |ident, value|
        identifiers[ident] ||= value
      end

      self
    end
Modifies this user record in place, adding attributes from the
 other user.  Merge rules:

 * For portals: the resulting portal list is a union of the
   portal list for this and the _other_ user.
 * For group memberships: group memberships are added from
   the _other_ user for all portals which this user doesn't
   already have group memberships.  (That is, the group
   membership lists for a particular portal are not merged.)
   This rule is to prevent ambiguity if different
   authorities have different group hierarchies.  In
   practice only one authority is providing authorization
   information for a portal, so this shouldn't matter.
 * For identifiers: any identifier in the _other_ user that is
   not already set in this user is copied over.
 * For all other attributes: an attribute is copied from
   _other_ if that attribute is not already set in this
   user.

 Note that these semantics are different from the semantics of
 `Hash#merge!` in the ruby standard library.

 @param [Aker::User] other the user from which to take attribute
   values

 @return [Aker::User] self