<commit_before>module HydraAttributesHelper
  def default_hydra_attribute_value(hydra_attribute)
    if hydra_attribute.default_value.nil?
      'nil'
    else
      '"' + hydra_attribute.default_value + '"'
    end
  end

  def hydra_attribute_fields_for(entity, form, submitted = false)
    entity.hydra_attribute_association.hydra_values.inject(''.html_safe) do |fields, (_,hydra_value)|
      name     = hydra_value.hydra_attribute.name
      disabled = !hydra_value.hydra_attribute.white_list

      fields + form_group(form, name, submitted) do
        case hydra_value.hydra_attribute.backend_type
        when 'string', 'integer', 'float', 'decimal'
          form.text_field name, class: 'form-control', disabled: disabled
        when 'text'
          form.text_area name, class: 'form-control', rows: 3, disabled: disabled
        when 'boolean'
          form.check_box name, disabled: disabled
        when 'datetime'
          form.datetime_select name, {}, disabled: disabled
        else
          raise 'Unknown backend type'
        end
      end
    end
  end
end<commit_msg>Uses select box for boolean attributes<commit_after>module HydraAttributesHelper
  def default_hydra_attribute_value(hydra_attribute)
    if hydra_attribute.default_value.nil?
      'nil'
    else
      '"' + hydra_attribute.default_value + '"'
    end
  end

  def hydra_attribute_fields_for(entity, form, submitted = false)
    entity.hydra_attribute_association.hydra_values.inject(''.html_safe) do |fields, (_,hydra_value)|
      name     = hydra_value.hydra_attribute.name
      disabled = !hydra_value.hydra_attribute.white_list

      fields + form_group(form, name, submitted) do
        case hydra_value.hydra_attribute.backend_type
        when 'string', 'integer', 'float', 'decimal'
          form.text_field name, class: 'form-control', disabled: disabled
        when 'text'
          form.text_area name, class: 'form-control', rows: 3, disabled: disabled
        when 'boolean'
          form.select name, options_for_select([['YES', true], ['NO', false]], hydra_value.value), {included_blank: false}, {class: 'form-control', disabled: disabled}
        when 'datetime'
          form.datetime_select name, {}, disabled: disabled
        else
          raise 'Unknown backend type'
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.09652509652509653, 'fraction_numerical': 0.000858000858000858, 'mean_word_length': 3.084063047285464, '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': '5435077', 'n_tokens_mistral': 712, 'n_tokens_neox': 672, 'n_words': 161}