<commit_before>module HatTrick
  module ControllerHelpers

    private

    def model_key
      params.each do |k,v|
        return k if v.is_a?(Hash) && is_model?(k)
      end
      nil
    end

    def params_model_name
      class_name model_key
    end

    def is_model?(model_name)
      begin
        class_name(model_name).constantize
      rescue NameError
        return false
      end
      true
    end

    def class_name(hash_key)
      hash_key.to_s.camelize
    end

    def model_class
      model_name = params_model_name
      return nil if model_name.nil?
      begin
        model_klass = params_model_name.constantize<commit_msg>return nil from params_model_name when no model_key<commit_after>module HatTrick
  module ControllerHelpers

    private

    def model_key
      params.each do |k,v|
        return k if v.is_a?(Hash) && is_model?(k)
      end
      nil
    end

    def params_model_name
      class_name model_key unless model_key.nil?
    end

    def is_model?(model_name)
      begin
        class_name(model_name).constantize
      rescue NameError
        return false
      end
      true
    end

    def class_name(hash_key)
      hash_key.to_s.camelize
    end

    def model_class
      model_name = params_model_name
      return nil if model_name.nil?
      begin
        model_klass = params_model_name.constantize
{'fraction_non_alphanumeric': 0.0469208211143695, 'fraction_numerical': 0.0, 'mean_word_length': 2.1744186046511627, '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': '2745965', 'n_tokens_mistral': 434, 'n_tokens_neox': 433, 'n_words': 105}