<commit_before>module StrongRoutes
  module Accessorable
    # Creates an accessor that simply sets and reads a key in the hash:
    #
    #   class Config < Hash
    #     hash_accessor :app
    #   end
    #
    #   config = Config.new
    #   config.app = Foo
    #   config[:app] #=> Foo
    #
    #   config[:app] = Bar
    #   config.app #=> Bar
    #
    def hash_accessor(*names) #:nodoc:
      names.each do |name|
        class_eval <<-METHOD, __FILE__, __LINE__ + 1
          def #{name}
            self[:#{name}]
          end

          def #{name}=(value)
            self[:#{name}] = value
          end

          def #{name}?
            self[:#{name}].nil?
          end
        METHOD
      end
    end
  end

  class Config < Hash
    extend Accessorable

    hash_accessor :allowed_routes,
                  :enabled,
                  :insert_after,
                  :insert_before,
                  :message

    def initialize(*)
      super

      self[:enabled] = true if self[:enabled].nil?
      self[:message] = "Resource Not Found" if self[:message].nil?
    end
  end
end
<commit_msg>Return false when config values are nil<commit_after>module StrongRoutes
  module Accessorable
    # Creates an accessor that simply sets and reads a key in the hash:
    #
    #   class Config < Hash
    #     hash_accessor :app
    #   end
    #
    #   config = Config.new
    #   config.app = Foo
    #   config[:app] #=> Foo
    #
    #   config[:app] = Bar
    #   config.app #=> Bar
    #
    def hash_accessor(*names) #:nodoc:
      names.each do |name|
        class_eval <<-METHOD, __FILE__, __LINE__ + 1
          def #{name}
            self[:#{name}]
          end

          def #{name}=(value)
            self[:#{name}] = value
          end

          def #{name}?
            !! self[:#{name}]
          end
        METHOD
      end
    end
  end

  class Config < Hash
    extend Accessorable

    hash_accessor :allowed_routes,
                  :enabled,
                  :insert_after,
                  :insert_before,
                  :message

    def initialize(*)
      super

      self[:enabled] = true if self[:enabled].nil?
      self[:message] = "Resource Not Found" if self[:message].nil?
    end
  end
end

{'fraction_non_alphanumeric': 0.10530973451327434, 'fraction_numerical': 0.0008849557522123894, 'mean_word_length': 1.537598204264871, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, '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': '4500981', 'n_tokens_mistral': 687, 'n_tokens_neox': 660, 'n_words': 182}