<commit_before>module TheRole::Owner

  def permit_with(the_role_user, options = {})
    refs = reflections.select { |_, v| the_role_user.class.name == v.class_name }
    refs = reflections.select { |_, v| the_role_user.class.base_class.name == v.class_name } if refs.blank?

    scope = {}
    refs.each do |_, ref|
      unless ref.through_reflection?
        scope[ref.foreign_key] = the_role_user.allow_ids
      end
    end

    default_or(scope)
  end

  def default_or(hash)
    return all if hash.blank?

    keys = hash.keys
    query = where(keys[0] => hash[keys[0]])

    keys[1..-1].each do |key|
      query = query.or(where(key => hash[key]))
    end

    query
  end

end

ActiveRecord::Base.extend TheRole::Owner<commit_msg>fix the role<commit_after>module TheRole::Owner

  def permit_with(the_role_user, options = {})
    refs = reflections.select { |_, v|
      !v.through_reflection? && the_role_user.class.name == v.class_name
    }
    refs = reflections.select { |_, v| !v.through_reflection? && the_role_user.class.base_class.name == v.class_name } if refs.blank?

    scope = {}
    refs.each do |_, ref|
      scope[ref.foreign_key] = the_role_user.allow_ids
    end

    default_or(scope)
  end

  def default_or(hash)
    return all if hash.blank?

    keys = hash.keys
    query = where(keys[0] => hash[keys[0]])

    keys[1..-1].each do |key|
      query = query.or(where(key => hash[key]))
    end

    query
  end

end

ActiveRecord::Base.extend TheRole::Owner
{'fraction_non_alphanumeric': 0.13136729222520108, 'fraction_numerical': 0.005361930294906166, 'mean_word_length': 3.024258760107817, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '6638131', 'n_tokens_mistral': 544, 'n_tokens_neox': 521, 'n_words': 104}