<commit_before>class ProjectPolicy < ApplicationPolicy
  def create?
    is_owned_by? user
  end

  def update?
    user.present? && (user.admin? || record.user == user)
  end

  def send_to_analysis?
    update?
  end

  def permitted_attributes
    if user.present? && (user.admin? || (record.draft? || record.rejected? || record.in_analysis?))
      {project: record.attribute_names}
    else
      {project: [:about, :video_url, :uploaded_image, :headline]}
    end
  end
end

<commit_msg>refactoring update? method to use is_owned_by? helper<commit_after>class ProjectPolicy < ApplicationPolicy
  def create?
    is_owned_by? user
  end

  def update?
    is_owned_by?(user) || user.try(:admin?)
  end

  def send_to_analysis?
    update?
  end

  def permitted_attributes
    if user.present? && (user.admin? || (record.draft? || record.rejected? || record.in_analysis?))
      {project: record.attribute_names}
    else
      {project: [:about, :video_url, :uploaded_image, :headline]}
    end
  end
end


{'fraction_non_alphanumeric': 0.11758893280632411, 'fraction_numerical': 0.0, 'mean_word_length': 3.5426008968609866, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7223591', 'n_tokens_mistral': 341, 'n_tokens_neox': 334, 'n_words': 80}