<commit_before>module Seek
  module Permissions
    module PolicyBasedAuthorization
      class AuthPermissions < Struct.new :can_view, :can_download, :can_edit, :can_manage, :can_delete
      end

      def self.included(klass)
        attr_accessor :permission_for
        klass.extend AuthLookupClassMethods
        klass.class_eval do
          belongs_to :contributor, polymorphic: true unless method_defined? :contributor
          after_initialize :contributor_or_default_if_new

          # checks a policy exists, and if missing resorts to using a private policy
          after_initialize :policy_or_default_if_new

          include Seek::ProjectAssociation unless method_defined? :projects

          belongs_to :policy, autosave: true
          enforce_required_access_for_owner :policy, :manage

          after_commit :check_to_queue_update_auth_table
          after_destroy :remove_from_lookup_table
          after_destroy { |record| record.policy.try(:destroy_if_redundant) }<commit_msg>OPSK-696 removed polymorphic nature of contributor<commit_after>module Seek
  module Permissions
    module PolicyBasedAuthorization
      class AuthPermissions < Struct.new :can_view, :can_download, :can_edit, :can_manage, :can_delete
      end

      def self.included(klass)
        attr_accessor :permission_for
        klass.extend AuthLookupClassMethods
        klass.class_eval do
          belongs_to :contributor, class_name: 'Person' unless method_defined? :contributor
          after_initialize :contributor_or_default_if_new

          # checks a policy exists, and if missing resorts to using a private policy
          after_initialize :policy_or_default_if_new

          include Seek::ProjectAssociation unless method_defined? :projects

          belongs_to :policy, autosave: true
          enforce_required_access_for_owner :policy, :manage

          after_commit :check_to_queue_update_auth_table
          after_destroy :remove_from_lookup_table
          after_destroy { |record| record.policy.try(:destroy_if_redundant) }
{'fraction_non_alphanumeric': 0.05019493177387914, 'fraction_numerical': 0.0014619883040935672, 'mean_word_length': 3.4341252699784017, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5557298', 'n_tokens_mistral': 567, 'n_tokens_neox': 548, 'n_words': 137}