Module: Kaui::UuidHelper

Defined in:
app/helpers/kaui/uuid_helper.rb

Instance Method Summary collapse

Instance Method Details

#object_id_popover(object_id, placement = 'right', title = nil) ⇒ Object



10
11
12
13
14
15
16
17
# File 'app/helpers/kaui/uuid_helper.rb', line 10

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

#truncate_uuid(uuid) ⇒ Object



4
5
6
7
8
# File 'app/helpers/kaui/uuid_helper.rb', line 4

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