<commit_before>require 'hashie/mash'

module Restforce
  class Mash < Hashie::Mash

    class << self

      # Pass in an Array or Hash and it will be recursively converted into the
      # appropriate Restforce::Collection, Restforce::SObject and
      # Restforce::Mash objects.
      def build(val, client)
        if val.is_a?(Array)
          val.collect { |e| self.type(e).new(e, client) }
        else
          self.type(val).new(val, client)
        end
      end

      # When passed a hash, it will determine what class is appropriate to
      # represent the data.
      def type(val)
        # When the hash has a records key, it should be considered a collection
        # of sobject records.
        if val.has_key? 'records'
          Restforce::Collection
        # When the has contains an attributes key, it should be considered an
        # sobject record
        elsif val.has_key? 'attributes'
          Restforce::SObject
        # Fallback to a standard Restforce::Mash for everything else
        else
          Restforce::Mash
        end
      end

    end

    def initialize(source_hash = nil, client = nil, default = nil, &blk)
      @client = client
      deep_update(source_hash) if source_hash
      default ? super(default) : super(&blk)
    end
  
    def convert_value(val, duping=false)<commit_msg>Cleanup.<commit_after>require 'hashie/mash'

module Restforce
  class Mash < Hashie::Mash

    class << self

      # Pass in an Array or Hash and it will be recursively converted into the
      # appropriate Restforce::Collection, Restforce::SObject and
      # Restforce::Mash objects.
      def build(val, client)
        if val.is_a?(Array)
          val.collect { |e| self.type(e).new(e, client) }
        else
          self.type(val).new(val, client)
        end
      end

      # When passed a hash, it will determine what class is appropriate to
      # represent the data.
      def type(val)
        if val.has_key? 'records'
          # When the hash has a records key, it should be considered a collection
          # of sobject records.
          Restforce::Collection
        elsif val.has_key? 'attributes'
          # When the hash contains an attributes key, it should be considered an
          # sobject record
          Restforce::SObject
        else
          # Fallback to a standard Restforce::Mash for everything else
          Restforce::Mash
        end
      end

    end

    def initialize(source_hash = nil, client = nil, default = nil, &blk)
      @client = client
      deep_update(source_hash) if source_hash
      default ? super(default) : super(&blk)
    end
  
    def convert_value(val, duping=false)
{'fraction_non_alphanumeric': 0.0766068759342302, 'fraction_numerical': 0.0, 'mean_word_length': 2.209832134292566, 'pattern_counts': {'":': 0, '<': 9, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6472503', 'n_tokens_mistral': 750, 'n_tokens_neox': 740, 'n_words': 261}