<commit_before>class Ability
  include CanCan::Ability

  def initialize(user)
    if user
        # Document
        can [:read, :open], Document.shared
        can [:index, :list, :create, :new, :all], Document
        can [:show, :edit, :update, :destroy, :save, :open], Document do |doc|
            doc.owner == user
        end

        # User
        can [:read, :update], User do |u|
          u == user
        end
    else
      # anonymous can't do anything
    end
  end
end<commit_msg>Allow everyone to read shared documents<commit_after>class Ability
  include CanCan::Ability

  def initialize(user)
    # Stuff everyone can do
    can [:read, :open], Document.shared

    if user
        # Document
        can [:index, :list, :create, :new, :all], Document
        can [:show, :edit, :update, :destroy, :save, :open], Document do |doc|
            doc.owner == user
        end

        # User
        can [:read, :update], User do |u|
          u == user
        end
    else
      # anonymous can't do anything
    end
  end
end
{'fraction_non_alphanumeric': 0.11365807067812798, 'fraction_numerical': 0.0, 'mean_word_length': 1.9942857142857142, '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': '3998002', 'n_tokens_mistral': 321, 'n_tokens_neox': 313, 'n_words': 110}