uuid_helper 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/uuid_helper.rb +31 -0
- data/lib/uuid_helper/version.rb +1 -1
- metadata +2 -2
data/lib/uuid_helper.rb
CHANGED
@@ -43,4 +43,35 @@ module UuidHelper
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
46
|
+
|
47
|
+
UUIDTools::UUID.class_eval do
|
48
|
+
#
|
49
|
+
# Returns this object as it is. Basically allows you to use to_uuid in an
|
50
|
+
# UUID object.
|
51
|
+
#
|
52
|
+
# It is easier for a method to just use param.to_uuid without
|
53
|
+
# wondering if the param is_a? String, Nil or UUIDTools::UUID class.
|
54
|
+
#
|
55
|
+
def to_uuid
|
56
|
+
self
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
Array.class_eval do
|
61
|
+
#
|
62
|
+
# Converts every item on the array to an UUIDTools::UUID object.
|
63
|
+
# Any value that does not respond to :to_uuid method will be
|
64
|
+
# returned as nil.to_uuid
|
65
|
+
#
|
66
|
+
def to_uuid
|
67
|
+
self.map do |v|
|
68
|
+
if v.respond_to? :to_uuid
|
69
|
+
v.to_uuid
|
70
|
+
else
|
71
|
+
nil.to_uuid
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
46
77
|
end
|
data/lib/uuid_helper/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uuid_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|