Sha256: fdf7ef373e891ddaba7b7e1f233dda42927a3a17d13f6eb7eb5618ef4895b3ca

Contents?: true

Size: 667 Bytes

Versions: 6

Compression:

Stored size: 667 Bytes

Contents

# frozen_string_literal: true

module Katalyst
  module Tables
    module Query
      class SuggestionComponent < ViewComponent::Base
        include Katalyst::HtmlAttributes

        delegate :type, :value, to: :@suggestion

        def initialize(suggestion:, **)
          super(**)

          @suggestion = suggestion
        end

        def default_html_attributes
          {
            class: ["suggestion", type.to_s],
          }
        end

        private

        def format_value(value)
          if /\A[\w.-]*\z/.match?(value.to_s)
            value.to_s
          else
            %("#{value}")
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
katalyst-tables-3.5.5 app/components/katalyst/tables/query/suggestion_component.rb
katalyst-tables-3.5.4 app/components/katalyst/tables/query/suggestion_component.rb
katalyst-tables-3.5.3 app/components/katalyst/tables/query/suggestion_component.rb
katalyst-tables-3.5.2 app/components/katalyst/tables/query/suggestion_component.rb
katalyst-tables-3.5.1 app/components/katalyst/tables/query/suggestion_component.rb
katalyst-tables-3.5.0 app/components/katalyst/tables/query/suggestion_component.rb