<commit_before>module Geotab
  module Concerns
    module Findable
      module ClassMethods

        def geotab_reference_name
          self.to_s.split("::").last.gsub("Datum", "Data")
        end

        def all(parent, params={})
          search = params.to_s.gsub(" ", "").gsub("=>", ":").gsub("\"", "'")

          response = Faraday.get("https://#{parent.path}/apiv1/Get",
                                 {typeName: geotab_reference_name,
                                  credentials: parent.credentials,
                                  search: search})
          
          attributes = JSON.parse(response.body).to_ostruct_recursive.result

          results = []

          if attributes && attributes.any?
            attributes.each do |result|
              results.push(new(result, parent))
            end
          end

          results
        end

        alias_method :where, :all
      end

      def self.included(base)
        base.extend(ClassMethods)
      end

    end
  end<commit_msg>added find method<commit_after>module Geotab
  module Concerns
    module Findable
      module ClassMethods

        def geotab_reference_name
          self.to_s.split("::").last.gsub("Datum", "Data")
        end

        def all(parent, params={})
          search = params.to_s.gsub(" ", "").gsub("=>", ":").gsub("\"", "'")

          response = Faraday.get("https://#{parent.path}/apiv1/Get",
                                 {typeName: geotab_reference_name,
                                  credentials: parent.credentials,
                                  search: search})
          
          attributes = JSON.parse(response.body).to_ostruct_recursive.result

          results = []

          if attributes && attributes.any?
            attributes.each do |result|
              results.push(new(result, parent))
            end
          end

          results
        end

        def find(parent, id)
          where(parent, {'id': "'#{id}'"})
        end

        alias_method :where, :all
      end

      def self.included(base)
        base.extend(ClassMethods)
      end

    end
  end
{'fraction_non_alphanumeric': 0.11576470588235294, 'fraction_numerical': 0.0009411764705882353, 'mean_word_length': 1.492379835873388, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1186750', 'n_tokens_mistral': 597, 'n_tokens_neox': 573, 'n_words': 114}