Class: Extant::Coercers::Uuid

Inherits:
Base
  • Object
show all
Defined in:
lib/extant/coercers/uuid.rb

Constant Summary collapse

UUID_REGEX =
/\A[\da-f]{8}-([\da-f]{4}-){3}[\da-f]{12}\z/i

Constants inherited from Base

Base::UncoercedValue

Instance Method Summary collapse

Methods inherited from Base

#coerced?, coercer_name, #initialize

Constructor Details

This class inherits a constructor from Extant::Coercers::Base

Instance Method Details

#coerceObject



5
6
7
8
9
10
11
12
# File 'lib/extant/coercers/uuid.rb', line 5

def coerce
  if value.to_s =~ UUID_REGEX
    self.coerced = true
    value.to_s
  else
    UncoercedValue
  end
end