<commit_before># frozen_string_literal: true
module Hyrax
  class Group
    DEFAULT_NAME_PREFIX = 'group/'

    def self.name_prefix
      DEFAULT_NAME_PREFIX
    end

    ##
    # @return [Hyrax::Group]
    def self.from_key(key)
      new(key.slice!(name_prefix))
    end

    def initialize(name)
      @name = name
    end

    attr_reader :name

    ##
    # @return [String] a local identifier for this group; for use (e.g.) in ACL
    #   data
    def group_key
      self.class.name_prefix + name
    end
    alias user_key group_key

    def to_sipity_agent
      sipity_agent || create_sipity_agent!
    end

    private

    def sipity_agent
      Sipity::Agent.find_by(proxy_for_id: name, proxy_for_type: self.class.name)
    end

    def create_sipity_agent!
      Sipity::Agent.create!(proxy_for_id: name, proxy_for_type: self.class.name)
    end
  end
end<commit_msg>implement equality for Hyrax::Group<commit_after># frozen_string_literal: true
module Hyrax
  class Group
    DEFAULT_NAME_PREFIX = 'group/'

    def self.name_prefix
      DEFAULT_NAME_PREFIX
    end

    ##
    # @return [Hyrax::Group]
    def self.from_key(key)
      new(key.slice!(name_prefix))
    end

    def initialize(name)
      @name = name
    end

    attr_reader :name

    ##
    # @return [Boolean]
    def ==(other)
      other.class == self.class &&
        other.name == self.name
    end

    ##
    # @return [String] a local identifier for this group; for use (e.g.) in ACL
    #   data
    def group_key
      self.class.name_prefix + name
    end
    alias user_key group_key

    def to_sipity_agent
      sipity_agent || create_sipity_agent!
    end

    private

    def sipity_agent
      Sipity::Agent.find_by(proxy_for_id: name, proxy_for_type: self.class.name)
    end

    def create_sipity_agent!
      Sipity::Agent.create!(proxy_for_id: name, proxy_for_type: self.class.name)
    end
  end
end
{'fraction_non_alphanumeric': 0.08686551543694401, 'fraction_numerical': 0.0, 'mean_word_length': 2.573831775700935, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '86711', 'n_tokens_mistral': 671, 'n_tokens_neox': 647, 'n_words': 151}