<commit_before>module FlyoverComments
  module Authorization

    def can_index_flyover_comments?(params, user)
      if Object.const_defined?("Pundit") && policy = Pundit.policy(user, params)
        policy.index?
      elsif user.respond_to?(:can_index_flyover_comments?)
        user.can_index_flyover_comments?(params)
      else
        true
      end
    end

    def can_hard_delete_flyover_comment?(comment, user)
      if Object.const_defined?("Pundit") && policy = Pundit.policy(user, comment)
        policy.hard_destroy?
      elsif user.respond_to?(:can_hard_delete_flyover_comment?)
        user.can_hard_delete_flyover_comment?(comment)
      else
        false
      end
    end

    def can_soft_delete_flyover_comment?(comment, user)
      if Object.const_defined?("Pundit") && policy = Pundit.policy(user, comment)
        policy.soft_destroy?
      elsif user.respond_to?(:can_soft_delete_flyover_comment?)
        user.can_soft_delete_flyover_comment?(comment)
      else
        comment._user == user
      end
    end

    def can_view_flyover_comment?(comment, user)
      if Object.const_defined?("Pundit") && policy = Pundit.policy(user, comment)
        policy.show?
      elsif user.respond_to?(:can_view_flyover_comment?)
        user.can_view_flyover_comment?(comment)
      else
        true
      end
    end

    def can_create_flyover_comment?(comment, user)
      if Object.const_defined?("Pundit") && policy = Pundit.policy(user, comment)
        policy.create?
      elsif user.respond_to?(:can_create_flyover_comment?)
        user.can_create_flyover_comment?(comment)
      else
        comment._user == user
      end
    end

    def can_update_flyover_comment?(comment, user)
      if Object.const_defined?("Pundit") && policy = Pundit.policy(user, comment)
        policy.update?
      elsif user.respond_to?(:can_update_flyover_comment?)
        user.can_update_flyover_comment?(comment)
      else
        comment._user == user
      end
    end

    def can_flag_flyover_comment?(comment, user)
      if Object.const_defined?("Pundit") && policy = Pundit.policy(user, FlyoverComments::Flag.new(:comment => comment, FlyoverComments.user_class_symbol => user))
        policy.create?
      elsif user.respond_to?(:can_flag_flyover_comment?)
        user.can_flag_flyover_comment?(comment)
      else
        !user.nil?
      end
    end

  end
end<commit_msg>policy for vote<commit_after>module FlyoverComments
  module Authorization

    def can_index_flyover_comments?(params, user)
      if Object.const_defined?("Pundit") && policy = Pundit.policy(user, params)
        policy.index?
      elsif user.respond_to?(:can_index_flyover_comments?)
        user.can_index_flyover_comments?(params)
      else
        true
      end
    end

    def can_hard_delete_flyover_comment?(comment, user)
      if Object.const_defined?("Pundit") && policy = Pundit.policy(user, comment)
        policy.hard_destroy?
      elsif user.respond_to?(:can_hard_delete_flyover_comment?)
        user.can_hard_delete_flyover_comment?(comment)
      else
        false
      end
    end

    def can_soft_delete_flyover_comment?(comment, user)
      if Object.const_defined?("Pundit") && policy = Pundit.policy(user, comment)
        policy.soft_destroy?
      elsif user.respond_to?(:can_soft_delete_flyover_comment?)
        user.can_soft_delete_flyover_comment?(comment)
      else
        comment._user == user
      end
    end

    def can_view_flyover_comment?(comment, user)
      if Object.const_defined?("Pundit") && policy = Pundit.policy(user, comment)
        policy.show?
      elsif user.respond_to?(:can_view_flyover_comment?)
        user.can_view_flyover_comment?(comment)
      else
        true
      end
    end

    def can_create_flyover_comment?(comment, user)
      if Object.const_defined?("Pundit") && policy = Pundit.policy(user, comment)
        policy.create?
      elsif user.respond_to?(:can_create_flyover_comment?)
        user.can_create_flyover_comment?(comment)
      else
        comment._user == user
      end
    end

    def can_update_flyover_comment?(comment, user)
      if Object.const_defined?("Pundit") && policy = Pundit.policy(user, comment)
        policy.update?
      elsif user.respond_to?(:can_update_flyover_comment?)
        user.can_update_flyover_comment?(comment)
      else
        comment._user == user
      end
    end

    def can_flag_flyover_comment?(comment, user)
      if Object.const_defined?("Pundit") && policy = Pundit.policy(user, FlyoverComments::Flag.new(:comment => comment, FlyoverComments.user_class_symbol => user))
        policy.create?
      elsif user.respond_to?(:can_flag_flyover_comment?)
        user.can_flag_flyover_comment?(comment)
      else
        !user.nil?
      end
    end

    def can_vote_flyover_comment?(comment, user)
      if Object.const_defined?("Pundit") && policy = Pundit.policy(user, FlyoverComments::Vote.new(:comment => comment, FlyoverComments.user_class_symbol => user))
        policy.create?
      elsif user.respond_to?(:can_vote_flyover_comment?)
        user.can_vote_flyover_comment?(comment)
      else
        !user.nil?
      end
    end


  end
end
{'fraction_non_alphanumeric': 0.09694171956145413, 'fraction_numerical': 0.0, 'mean_word_length': 3.1074249605055293, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '7304252', 'n_tokens_mistral': 1648, 'n_tokens_neox': 1651, 'n_words': 268}