<commit_before>module Admin::SerializeHelper
  
  def get_keys(model, attribute)
    config = begin
        c = Typus::Configuration.config[model.class.to_s]['fields']['options']['serialize'][attribute.to_s]
        c.split(',').collect {|t| t.strip.humanize }.to_json
      rescue []
    end
    raw config
  end

  def get_name(model, attribute)
    model = model.class.to_s.underscore
    name = "#{model}[#{attribute}]"
  end

  def get_json(model, attribute)
    items = model[attribute].delete_if { |x| x == "" } rescue nil
    raw items.values.to_json rescue []
  end

  def get_limit(model, attribute)
    limit = Typus::Configuration.config[model.class.to_s]['fields']['options']['serialize']['options']['limit'][attribute.to_s] rescue []
  
    case limit<commit_msg>fix for namespaced models<commit_after>module Admin::SerializeHelper
  
  def get_keys(model, attribute)
    config = begin
        c = Typus::Configuration.config[model.class.to_s]['fields']['options']['serialize'][attribute.to_s]
        c.split(',').collect {|t| t.strip.humanize }.to_json
      rescue []
    end
    raw config
  end

  def get_name(model, attribute)
    model = ActiveModel::Naming.param_key(model) # => model_name
    name = "#{model}[#{attribute}]"
  end

  def get_json(model, attribute)
    items = model[attribute].delete_if { |x| x == "" } rescue nil
    raw items.values.to_json rescue []
  end

  def get_limit(model, attribute)
    limit = Typus::Configuration.config[model.class.to_s]['fields']['options']['serialize']['options']['limit'][attribute.to_s] rescue []
  
    case limit
{'fraction_non_alphanumeric': 0.1552482715273413, 'fraction_numerical': 0.0, 'mean_word_length': 3.928792569659443, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '4723107', 'n_tokens_mistral': 502, 'n_tokens_neox': 503, 'n_words': 97}