Sha256: 5d07fd85b7b9e2e1d79358f13796cef3ea0e922d44c677d84bb733bfba02ccf5

Contents?: true

Size: 652 Bytes

Versions: 2

Compression:

Stored size: 652 Bytes

Contents

# frozen_string_literal: true

module FoxTail::Concerns::Identifiable
  extend ActiveSupport::Concern

  class_methods do
    def generate_unique_id
      "#{name.underscore.gsub("_component", "").gsub("/", "_")}_#{SecureRandom.base58(6)}"
    end
  end

  def id
    html_attributes[:id] ||= self.class.generate_unique_id
  end
  alias_method :generate_unique_id, :id

  private

  def __id_argument_deprecated_warning(slot: false)
    FoxTail.deprecator.allow ["identifiable"] do
      callstack = Array(caller_locations[slot ? 7 : 4])
      FoxTail.deprecator.warn "first argument `id` is deprecated, use `id:` instead", callstack
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fox_tail-0.2.1 app/components/fox_tail/concerns/identifiable.rb
fox_tail-0.2.0 app/components/fox_tail/concerns/identifiable.rb