<commit_before>module Stradivari
  module Filter

    class Generator < Stradivari::Generator
      NAMESPACE = Filter::NAMESPACE

      FILTER_OPTIONS = {
        detached: false,
        inline: false,
        class: 'filter-form-container ',
        id:    'filter-form'
      }

      class Field < Tag
        def initialize(parent, scope, name, opts, &renderer)
          super(parent, opts)

          @scope    = scope
          @name     = name

          if renderer.present?
            @renderer = renderer

            raise ArgumentError, "To use custom field you need to provide active attribute block inside options" unless opts.has_key?(:active)

            @active = if (active_block = @opts.fetch(:active, nil))
              view.instance_exec(&active_block)
            else
              false
            end
          end

          @opts.merge!(
            namespace: NAMESPACE,
            is_column: klass.columns_hash[@<EMAIL>.to_s].present?,
            is_scoped: klass._ransackers[@name.to_s].present?<commit_msg>now you can pass :active parameter even without a custom renderer for custom filters<commit_after>module Stradivari
  module Filter

    class Generator < Stradivari::Generator
      NAMESPACE = Filter::NAMESPACE

      FILTER_OPTIONS = {
        detached: false,
        inline: false,
        class: 'filter-form-container ',
        id:    'filter-form'
      }

      class Field < Tag
        def initialize(parent, scope, name, opts, &renderer)
          super(parent, opts)

          @scope    = scope
          @name     = name
          @active   = if (active_block = @opts.fetch(:active, nil))
            view.instance_exec(&active_block)
          else
            false
          end

          if renderer.present?
            raise ArgumentError, "To use custom field you need to provide active attribute block inside options" unless opts.has_key?(:active)
            @renderer = renderer
          end

          @opts.merge!(
            namespace: NAMESPACE,
            is_column: klass.columns_hash[@<EMAIL>.to_s].present?,
            is_scoped: klass._ransackers[@<EMAIL>_s].present?
{'fraction_non_alphanumeric': 0.08732001857872736, 'fraction_numerical': 0.0, 'mean_word_length': 1.9147496617050068, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 6, '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': '5376294', 'n_tokens_mistral': 590, 'n_tokens_neox': 581, 'n_words': 154}