<commit_before>module Immedialist
  module TMDB
    class TMDBResource < APIResource
      def initialize(attributes)
        @query_result = attributes.symbolize_keys
        @tmdb_id = @query_result[:id]
      end

      def find
        @query_result = query_api.try(:symbolize_keys)
        compare_results_to_api_expectations!
        self
      end

      def method_missing(method_name)
        if active_attributes.include?(method_name)
          return query_result[method_name]
        else
          super
        end
      end

      private

      attr_reader :tmdb_id, :query_result

      def compare_results_to_api_expectations!
        if !query_result.is_a?(Hash)
          raise TypeError, "Query result is not a Hash"
        end

        if query_result["status_code"] == 34
          raise TMDB::QueryError,
            "TMDB could not find a movie with ID #{tmdb_id}"
        end
      end
    end
  end<commit_msg>Immedialist::TMDB::TMDBResource: make #tmdb_id public<commit_after>module Immedialist
  module TMDB
    class TMDBResource < APIResource
      attr_reader :tmdb_id

      def initialize(attributes)
        @query_result = attributes.symbolize_keys
        @tmdb_id = @query_result[:id]
      end

      def find
        @query_result = query_api.try(:symbolize_keys)
        compare_results_to_api_expectations!
        self
      end

      def method_missing(method_name)
        if active_attributes.include?(method_name)
          return query_result[method_name]
        else
          super
        end
      end

      private

      attr_reader :query_result

      def compare_results_to_api_expectations!
        if !query_result.is_a?(Hash)
          raise TypeError, "Query result is not a Hash"
        end

        if query_result["status_code"] == 34
          raise TMDB::QueryError,
            "TMDB could not find a movie with ID #{tmdb_id}"
        end
      end
    end
  end
{'fraction_non_alphanumeric': 0.060496380558428126, 'fraction_numerical': 0.002068252326783868, 'mean_word_length': 2.161764705882353, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4731137', 'n_tokens_mistral': 589, 'n_tokens_neox': 572, 'n_words': 135}