blob: 28abdbd07343bc588b8f1ab950783ceaee47f66e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# frozen_string_literal: true
module ActiveRecord
module ConnectionAdapters
module PostgreSQL
module OID # :nodoc:
class Uuid < Type::Value # :nodoc:
ACCEPTABLE_UUID = %r{\A(\{)?([a-fA-F0-9]{4}-?){8}(?(1)\}|)\z}
alias_method :serialize, :deserialize
def type
:uuid
end
private
def cast_value(value)
casted = value.to_s
casted if casted.match?(ACCEPTABLE_UUID)
end
end
end
end
end
end
|