<commit_before>require 'cancan'

module Forem
  module Ability
    include CanCan::Ability

    def self.included(target)
      target.class_eval do
        # Alias old class's initialize so we can get it to after
        # Otherwise initialize attempts to go to an initialize that doesn't take an arg
        alias_method :old_initialize, :initialize

        def initialize(user)
          # Let other permissions run before this
          old_initialize(user)

          user ||= User.new # anonymous user

          if user.can_read_forums?
            can :read, Forem::Forum do |forum|
              user.can_read_forum?(forum)
            end
          end
        end
      end
    end<commit_msg>Use new 'namespaced' methods in Forem::Ability<commit_after>require 'cancan'

module Forem
  module Ability
    include CanCan::Ability

    def self.included(target)
      target.class_eval do
        # Alias old class's initialize so we can get it to after
        # Otherwise initialize attempts to go to an initialize that doesn't take an arg
        alias_method :old_initialize, :initialize

        def initialize(user)
          # Let other permissions run before this
          old_initialize(user)

          user ||= User.new # anonymous user

          if user.can_read_forem_forums?
            can :read, Forem::Forum do |forum|
              user.can_read_forem_forum?(forum)
            end
          end
        end
      end
    end
{'fraction_non_alphanumeric': 0.0577319587628866, 'fraction_numerical': 0.0, 'mean_word_length': 2.0847457627118646, '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': '5495448', 'n_tokens_mistral': 406, 'n_tokens_neox': 386, 'n_words': 134}