<commit_before>module ResqueSafe
  module ConvertFromHash
    def to_objects(inbound_hash)
      objects = {}
      inbound_hash.each do |klass_name,value|
        klass_name, value = klass_name.to_s, value.to_s
        klassified_klass = klass_name.classify
        symbolized_klass = klass_name.to_sym

        if Object.const_defined?(klassified_klass) &&
          known_models.include?(klassified_klass.constantize)

          objects[symbolized_klass] = return_active_record(klassified_klass, value)
        else
          objects[symbolized_klass] = return_other_object(klass_name, value)
        end
      end

      objects
    end

    def args_to_instance_vars(args)
      #take each key, if a model, make it an @#{model} = model.find(value)
      #else make it a @#{name}=#{value}

      args.each do |klass_name,value|
        klass_name, value = klass_name.to_s, value.to_s
        klassified_klass = klass_name.classify

        if Object.const_defined?(klassified_klass) &&
          known_models.include?(klassified_klass.constantize)

          set_for_active_record(klassified_klass, value)
        else
          set_for_other(klass_name, value)
        end
      end
    end

    private
    def return_active_record(klass_name, value)
      return self.instance_eval("#{klass_name.constantize}.find(#{value})")
    end

    def return_other_object(klass_name, value)
      if value.is_a?(String)
        return self.instance_eval("%|#{value}|")
      else
        return self.instance_eval(":#{instance_name} => #{value}")
      end

    end<commit_msg>Fix for incorrect emthod call<commit_after>module ResqueSafe
  module ConvertFromHash
    def to_objects(inbound_hash)
      objects = {}
      inbound_hash.each do |klass_name,value|
        klass_name, value = klass_name.to_s, value.to_s
        klassified_klass = klass_name.classify
        symbolized_klass = klass_name.to_sym

        if Object.const_defined?(klassified_klass) &&
          known_models.include?(klassified_klass.constantize)

          objects[symbolized_klass] = return_active_record(klassified_klass, value)
        else
          objects[symbolized_klass] = return_other_object(klass_name, value)
        end
      end

      objects
    end

    def args_to_instance_vars(args)
      #take each key, if a model, make it an @#{model} = model.find(value)
      #else make it a @#{name}=#{value}

      args.each do |klass_name,value|
        klass_name, value = klass_name.to_s, value.to_s
        klassified_klass = klass_name.classify

        if Object.const_defined?(klassified_klass) &&
          known_models.include?(klassified_klass.constantize)

          set_instance_for_active_record(klassified_klass, value)
        else
          set_instance_for_other(klass_name, value)
        end
      end
    end

    private
    def return_active_record(klass_name, value)
      return self.instance_eval("#{klass_name.constantize}.find(#{value})")
    end

    def return_other_object(klass_name, value)
      if value.is_a?(String)
        return self.instance_eval("%|#{value}|")
      else
        return self.instance_eval(":#{instance_name} => #{value}")
      end

    end
{'fraction_non_alphanumeric': 0.09045226130653267, 'fraction_numerical': 0.0, 'mean_word_length': 2.879415347137637, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 5, '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': '1670802', 'n_tokens_mistral': 981, 'n_tokens_neox': 1048, 'n_words': 183}