<commit_before>module Savon::So24
  module Model
    class Base
      extend Operations



      #several methods for the connect - disconnect
      def self.reconnect
        clean_headers
        global(:headers, { 'cookie' => Auth.connect})
      end

      def self.clean_headers
        client.globals[:headers].present? &&  client.globals[:headers].delete('cookie')
      end

      def self.request(operation, *args)
        #we will re-set this header every time just to be sure it is set
        global(:headers, { 'cookie' => Auth.cookie})
        begin
          super
        rescue Savon::SOAPFault => ex
          if ex.is_auth_not_logged?
            reconnect && super
          else
            raise ex
          end
        end
      end


      #the request methods, trying to make them common for all models
      def self.create data
        request "save_#{snake_name}", "#{snake_name}_item" => data
      end

      #this is a base method for most part of requests
      #probably will be overwritter for a number of models
      def self.where params = {}
        res = request(search_action_name, "#{snake_name}_search" =>params)
        ret = res && res["#{snake_name}_item".to_sym] || []
        ret.is_a?(Array) ? ret : [ret]
      end

      def self.find id
        where(id:id).first
      end

      def self.all
        where
      end
<commit_msg>creating connect/connected interface<commit_after>module Savon::So24
  module Model
    class Base
      extend Operations



      #several methods for the connect - disconnect
      def self.connect
        clean_headers
        global(:headers, { 'cookie' => Auth.connect})
      end

      def self.connected?
        Auth.connected?
      end

      def self.clean_headers
        client.globals[:headers].present? &&  client.globals[:headers].delete('cookie')
      end

      def self.request(operation, *args)
        #we will re-set this header every time just to be sure it is set
        global(:headers, { 'cookie' => Auth.cookie})
        begin
          super
        rescue Savon::SOAPFault => ex
          if ex.is_auth_not_logged?
            connect && super
          else
            raise ex
          end
        end
      end


      #the request methods, trying to make them common for all models
      def self.create data
        request "save_#{snake_name}", "#{snake_name}_item" => data
      end

      #this is a base method for most part of requests
      #probably will be overwritter for a number of models
      def self.where params = {}
        res = request(search_action_name, "#{snake_name}_search" =>params)
        ret = res && res["#{snake_name}_item".to_sym] || []
        ret.is_a?(Array) ? ret : [ret]
      end

      def self.find id
        where(id:id).first
      end

      def self.all
        where
      end

{'fraction_non_alphanumeric': 0.08966244725738397, 'fraction_numerical': 0.0014064697609001407, 'mean_word_length': 1.9543094496365525, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '7561247', 'n_tokens_mistral': 815, 'n_tokens_neox': 791, 'n_words': 250}