<commit_before>require 'active_support/ordered_hash'

# Usually key value pairs are handled something like this:
#
#   h = {}
#   h[:boy] = 'John'
#   h[:girl] = 'Mary'
#   h[:boy]  # => 'John'
#   h[:girl] # => 'Mary'
#
# Using <tt>OrderedOptions</tt>, the above code could be reduced to:
#
#   h = ActiveSupport::OrderedOptions.new
#   h.boy = 'John'
#   h.girl = 'Mary'
#   h.boy  # => 'John'
#   h.girl # => 'Mary'
#
module ActiveSupport #:nodoc:
  class OrderedOptions < OrderedHash
    alias_method :_get, :[] # preserve the original #[] method
    protected :_get # make it protected

    def []=(key, value)
      super(key.to_sym, value)
    end

    def [](key)
      super(key.to_sym)
    end

    def method_missing(name, *args)
      if name.to_s =~ /(.*)=$/
        self[$1] = args.first
      else
        self[name]
      end
    end

    def respond_to?(name)<commit_msg>Replace regexp matching with a simple string manipulation.<commit_after>require 'active_support/ordered_hash'

# Usually key value pairs are handled something like this:
#
#   h = {}
#   h[:boy] = 'John'
#   h[:girl] = 'Mary'
#   h[:boy]  # => 'John'
#   h[:girl] # => 'Mary'
#
# Using <tt>OrderedOptions</tt>, the above code could be reduced to:
#
#   h = ActiveSupport::OrderedOptions.new
#   h.boy = 'John'
#   h.girl = 'Mary'
#   h.boy  # => 'John'
#   h.girl # => 'Mary'
#
module ActiveSupport #:nodoc:
  class OrderedOptions < OrderedHash
    alias_method :_get, :[] # preserve the original #[] method
    protected :_get # make it protected

    def []=(key, value)
      super(key.to_sym, value)
    end

    def [](key)
      super(key.to_sym)
    end

    def method_missing(name, *args)
      name_string = name.to_s
      if name_string.chomp!('=')
        self[name_string] = args.first
      else
        self[name]
      end
    end

    def respond_to?(name)
{'fraction_non_alphanumeric': 0.1514500537056928, 'fraction_numerical': 0.0005370569280343716, 'mean_word_length': 2.7409638554216866, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, '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': '6074868', 'n_tokens_mistral': 678, 'n_tokens_neox': 660, 'n_words': 166}