<commit_before>module Acts #:nodoc:
  module Authorized #:nodoc:
    def self.included(ar)
      ar.const_get(:Base).class_eval { include BaseExtensions }
      ar.module_eval { include AuthorizationEnforcement }
      ar.const_get(:Base).class_eval { does_not_require_can_edit :uuid, :first_letter }
    end

    AUTHORIZATION_ACTIONS = [:view, :edit, :download, :delete, :manage]

    module BaseExtensions
      def self.included base
        base.extend ClassMethods
      end

      #Sets up the basic interface for authorization hooks. All AR instances get these methods, and by default they return true.
      AUTHORIZATION_ACTIONS.each do |action|
        define_method "can_#{action}?" do
          true
        end

        def can_perform? action, *args
          send "can_#{action}?", *args
        end
      end

      def authorization_supported?
        self.class.authorization_supported?
      end

      def contributor_credited?
        false
      end

      def title_is_public?
        false
      end

      def publish!
        if can_manage?
          policy.access_type=Policy::ACCESSIBLE
          policy.sharing_scope=Policy::EVERYONE
          policy.save
        else
          false
        end
      end

      def is_published?
        can_download? nil
      end

      module ClassMethods
        def acts_as_authorized
          include Acts::Authorized::PolicyBasedAuthorization
          include Acts::Authorized::CodeBasedAuthorization
        end

        def authorization_supported?
          include?(Acts::Authorized::PolicyBasedAuthorization)<commit_msg>touch the owner when updating the policy<commit_after>module Acts #:nodoc:
  module Authorized #:nodoc:
    def self.included(ar)
      ar.const_get(:Base).class_eval { include BaseExtensions }
      ar.module_eval { include AuthorizationEnforcement }
      ar.const_get(:Base).class_eval { does_not_require_can_edit :uuid, :first_letter }
    end

    AUTHORIZATION_ACTIONS = [:view, :edit, :download, :delete, :manage]

    module BaseExtensions
      def self.included base
        base.extend ClassMethods
      end

      #Sets up the basic interface for authorization hooks. All AR instances get these methods, and by default they return true.
      AUTHORIZATION_ACTIONS.each do |action|
        define_method "can_#{action}?" do
          true
        end

        def can_perform? action, *args
          send "can_#{action}?", *args
        end
      end

      def authorization_supported?
        self.class.authorization_supported?
      end

      def contributor_credited?
        false
      end

      def title_is_public?
        false
      end

      def publish!
        if can_manage?
          policy.access_type=Policy::ACCESSIBLE
          policy.sharing_scope=Policy::EVERYONE
          policy.save
          touch
        else
          false
        end
      end

      def is_published?
        can_download? nil
      end

      module ClassMethods
        def acts_as_authorized
          include Acts::Authorized::PolicyBasedAuthorization
          include Acts::Authorized::CodeBasedAuthorization
        end

        def authorization_supported?
          include?(Acts::Authorized::PolicyBasedAuthorization)
{'fraction_non_alphanumeric': 0.06475485661424607, 'fraction_numerical': 0.0, 'mean_word_length': 2.283400809716599, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1042475', 'n_tokens_mistral': 894, 'n_tokens_neox': 854, 'n_words': 226}