Class: Uploadcare::Rails::IdExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/uploadcare/rails/services/id_extractor.rb

Overview

A class extracting an ID of an object from an URL.

Class Method Summary collapse

Class Method Details

.call(input_str, regex = /\b[0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}\b/) ⇒ Object

regex is an UUID-regex by default



9
10
11
# File 'lib/uploadcare/rails/services/id_extractor.rb', line 9

def call(input_str, regex = /\b[0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}\b/)
  input_str.match(regex).to_s
end