blob: 033e0324bbb1da52e173e69a947807f5b2c1623a (
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
27
28
|
module ActiveRecord
module ConnectionAdapters
module PostgreSQL
module OID # :nodoc:
class Uuid < Type::Value # :nodoc:
RFC_4122 = %r{\A\{?[a-fA-F0-9]{4}-?
[a-fA-F0-9]{4}-?
[a-fA-F0-9]{4}-?
[1-5][a-fA-F0-9]{3}-?
[8-Bab][a-fA-F0-9]{3}-?
[a-fA-F0-9]{4}-?
[a-fA-F0-9]{4}-?
[a-fA-F0-9]{4}-?\}?\z}x
alias_method :type_cast_for_database, :type_cast_from_database
def type
:uuid
end
def type_cast(value)
value.to_s[RFC_4122, 0]
end
end
end
end
end
end
|