Class: IknowParams::Serializer::UUID
- Inherits:
-
String
- Object
- IknowParams::Serializer
- String
- IknowParams::Serializer::UUID
- Defined in:
- lib/iknow_params/serializer.rb
Instance Attribute Summary
Attributes inherited from IknowParams::Serializer
Instance Method Summary collapse
Methods inherited from String
Methods inherited from IknowParams::Serializer
#dump, for, for!, #initialize, json_value?, #matches_type!, singleton
Constructor Details
This class inherits a constructor from IknowParams::Serializer::String
Instance Method Details
#load(str) ⇒ Object
238 239 240 241 242 243 244 245 246 |
# File 'lib/iknow_params/serializer.rb', line 238 def load(str) matches_type!(str, err: LoadError) # UUIDs in Ruby are typically represented as lower case strings, # for example, as returned by SecureRandom.uuid. To avoid surprises, # and ensure that two equivalent UUIDs are equal to each other, we # canonicalize any provided strings to lower case. super.downcase end |
#matches_type?(str) ⇒ Boolean
248 249 250 |
# File 'lib/iknow_params/serializer.rb', line 248 def matches_type?(str) super && /[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}/i.match?(str) end |