<commit_before>require 'forwardable'

module IIIF
  module HashBehaviours
    extend Forwardable

    # TODO:
    #  * reject
    #  * replace

    def_delegators :@data, :[], :[]=, :camelize_keys, :delete, :empty?,
    :fetch, :has_key?, :has_value?, :include?, :insert, :insert_after,
    :insert_before, :key, :key?, :keys, :length, :member?, :shift, :size,
    :snakeize_keys, :store, :unshift, :value?, :values


    ###
    # Methods that take a block and should return an instance (self or a new'
    # instance) have been overridden to do so, rather than an'
    # IIIF::OrderedHash based on the internal hash

    SIMPLE_SELF_RETURNERS = %w[delete_if each each_key each_value keep_if]

    SIMPLE_SELF_RETURNERS.each do |method_name|
      define_method(method_name) do |*arg, &block|
        unless block.nil? # block_given? doesn't seem to work in this context
          @data.send(method_name, *arg, &block)
          return self
        else
          @data.send(method_name)<commit_msg>Add #dig to the IIIF models<commit_after>require 'forwardable'

module IIIF
  module HashBehaviours
    extend Forwardable

    # TODO:
    #  * reject
    #  * replace

    def_delegators :@data, :[], :[]=, :camelize_keys, :delete, :dig, :empty?,
    :fetch, :has_key?, :has_value?, :include?, :insert, :insert_after,
    :insert_before, :key, :key?, :keys, :length, :member?, :shift, :size,
    :snakeize_keys, :store, :unshift, :value?, :values


    ###
    # Methods that take a block and should return an instance (self or a new'
    # instance) have been overridden to do so, rather than an'
    # IIIF::OrderedHash based on the internal hash

    SIMPLE_SELF_RETURNERS = %w[delete_if each each_key each_value keep_if]

    SIMPLE_SELF_RETURNERS.each do |method_name|
      define_method(method_name) do |*arg, &block|
        unless block.nil? # block_given? doesn't seem to work in this context
          @data.send(method_name, *arg, &block)
          return self
        else
          @data.send(method_name)
{'fraction_non_alphanumeric': 0.11732673267326732, 'fraction_numerical': 0.0, 'mean_word_length': 3.3276231263383296, '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': '7559783', 'n_tokens_mistral': 685, 'n_tokens_neox': 661, 'n_words': 195}