<commit_before>module Appilf

  class AppilfObject

    attr_accessor :meta
    attr_accessor :links
    attr_accessor :item_data

    def meta
      @meta ||= {}
    end

    def links
      @links ||= {}
    end

    def initialize(api_element_hash)
      initialize_meta_data(api_element_hash)
      self.item_data = api_element_hash['data'].methodize!
    end

    def initialize_meta_data(api_element_hash)
      self.meta = api_element_hash.fetch('data', {}).delete('meta')
      self.links = api_element_hash.fetch('data', {}).delete('links')
      self.meta.methodize! if self.meta
      self.links.methodize! if self.links
    end

    def method_missing(name)
      return self.item_data.send(name) if self.item_data
      super
    end

  end

end<commit_msg>do not assume existence of data on api response<commit_after>module Appilf

  class AppilfObject

    attr_accessor :meta
    attr_accessor :links
    attr_accessor :item_data

    def meta
      @meta ||= {}
    end

    def links
      @links ||= {}
    end

    def item_data
      @item_data ||= {}
    end

    def initialize(api_element_hash)
      initialize_meta_data(api_element_hash)
      self.item_data = api_element_hash.fetch('data', {}).methodize!
    end

    def initialize_meta_data(api_element_hash)
      self.meta = api_element_hash.fetch('data', {}).delete('meta')
      self.links = api_element_hash.fetch('data', {}).delete('links')
      self.meta.methodize!
      self.links.methodize!
    end

    def method_missing(name)
      return self.item_data.send(name) if self.item_data
      super
    end

  end

end
{'fraction_non_alphanumeric': 0.10074626865671642, 'fraction_numerical': 0.0, 'mean_word_length': 2.830952380952381, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7191683', 'n_tokens_mistral': 536, 'n_tokens_neox': 518, 'n_words': 106}