<commit_before>module ActiveAdminAddons
  module EnumTag
    class << self
      def tag(context, model, attribute, options)
        state = model.send(attribute)
        raise 'you need to install enumerize gem first' unless defined? Enumerize::Value
        raise 'you need to pass an enumerize attribute' unless state.is_a?('Enumerize::Value'.constantize)
        context.status_tag(state.text, state)
      end
    end
  end

  module ::ActiveAdmin
    module Views
      class TableFor
        def tag_column(attribute, options = {})
          column(attribute) { |model| EnumTag.tag(self, model, attribute, options) }
        end
      end
      class AttributesTable
        def tag_row(attribute, options = {})
          row(attribute) { |model| EnumTag.tag(self, model, attribute, options) }
        end
      end
    end
  end
end<commit_msg>feat(Enum): Add support for blocks and labels<commit_after>module ActiveAdminAddons
  module EnumTag
    class << self
      def tag(context, model, attribute, &block)
        state = model.send(attribute)
        state = block.call(model) if block
        raise 'you need to install enumerize gem first' unless defined? Enumerize::Value
        raise 'you need to pass an enumerize attribute' unless state.is_a?('Enumerize::Value'.constantize)
        context.status_tag(state.text, state)
      end
    end
  end

  module ::ActiveAdmin
    module Views
      class TableFor
        def tag_column(*args, &block)
          attribute = args[1] || args[0]
          column(*args) { |model| EnumTag.tag(self, model, attribute, &block) }
        end
      end
      class AttributesTable
        def tag_row(*args, &block)
          attribute = args[1] || args[0]
          row(*args) { |model| EnumTag.tag(self, model, attribute, &block) }
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.09289617486338798, 'fraction_numerical': 0.002185792349726776, 'mean_word_length': 2.5692007797270957, 'pattern_counts': {'":': 0, '<': 7, '<?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': '7647354', 'n_tokens_mistral': 519, 'n_tokens_neox': 518, 'n_words': 159}