Sha256: 08b1f76951d6f57cc0e620efd5423d0ae818514e113c709adb843a152a100685

Contents?: true

Size: 639 Bytes

Versions: 1

Compression:

Stored size: 639 Bytes

Contents

module Kaui
  module UuidHelper

    def truncate_uuid(uuid)
      return uuid unless uuid =~ /[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}/
      split = uuid.split('-')
      split[0] + '-...-' + split[4]
    end
    module_function :truncate_uuid

    def object_id_popover(object_id, placement = 'right', title = nil)
      content_tag(:span, truncate_uuid(object_id),
                  id: "#{object_id}-popover", class: 'object-id-popover', title: title,
                  data: {
                      id: object_id,
                      placement: placement,
                  } )
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kaui-2.1.0 app/helpers/kaui/uuid_helper.rb