uuids 1.0.2 → 1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.rdoc +6 -5
- data/lib/uuids/base.rb +12 -2
- data/lib/uuids/version.rb +1 -1
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +309 -19780
- data/spec/lib/uuids/base_spec.rb +6 -0
- metadata +2 -6
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/log/development.log +0 -373
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90ebf6afbe59d579cfd3529c5ba780219a1267ba
|
4
|
+
data.tar.gz: d4468af5f78da1e7ae760019e1dc59f48fa648dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 198aea4684f2e4aa6ca7c9cc77e834d85f8c8057c393263ba1ce3b968d416636f6cd2002bc0e6b60a0af557e913f36d0f74676ed8d09f83ecbf565bddee06448
|
7
|
+
data.tar.gz: c80ee9a969326a6da8229aaf74c8549969d0d919b10362ccc1e6f998decfc65e8fa44f350c311c19355bc9b34d2b131d83d1bb006088e629daf2e4c60645ccf2
|
data/README.rdoc
CHANGED
@@ -103,13 +103,14 @@ This will add methods:
|
|
103
103
|
The first uuid is added by default. It can also be set manually:
|
104
104
|
|
105
105
|
# UUID is generated by default
|
106
|
-
city = City.
|
107
|
-
city.
|
106
|
+
city = City.create!
|
107
|
+
city.uuid.nil?
|
108
|
+
# => false
|
108
109
|
|
109
110
|
# UUID is assigned manually
|
110
|
-
city = City.
|
111
|
-
city.
|
112
|
-
|
111
|
+
city = City.create! uuid: "6d9456a9-8f54-4ff7-ba0d-9854f1954417"
|
112
|
+
city.uuid
|
113
|
+
# => "6d9456a9-8f54-4ff7-ba0d-9854f1954417"
|
113
114
|
|
114
115
|
The destruction of object is forbidden if it has a +uuid+. You should reassign
|
115
116
|
all object's UUIDs to another object in advance.
|
data/lib/uuids/base.rb
CHANGED
@@ -11,8 +11,10 @@ module Uuids
|
|
11
11
|
|
12
12
|
# Declares:
|
13
13
|
#
|
14
|
-
# +uuids+:: association attribute
|
15
|
-
# +uuid+:: method (string)
|
14
|
+
# +uuids+:: association attribute.
|
15
|
+
# +uuid+:: method (string).
|
16
|
+
# <tt>uuid=</tt>:: new uuid's value assignment.
|
17
|
+
# An alias for <tt>#uuids.new value: value</tt>
|
16
18
|
# <tt>uuid</tt>:: relation scope.
|
17
19
|
#
|
18
20
|
# @example
|
@@ -28,12 +30,15 @@ module Uuids
|
|
28
30
|
# city.uuid
|
29
31
|
# # => 51f50391-fcd2-4f69-aab7-6ef31b29c379
|
30
32
|
#
|
33
|
+
# city.uuid = "51f50391-fcd2-4f69-aab7-6ef31b29c379"
|
34
|
+
#
|
31
35
|
# City.by_uuid("51f50391-fcd2-4f69-aab7-6ef31b29c379").to_a == [city]
|
32
36
|
# # => true
|
33
37
|
#
|
34
38
|
def has_uuids
|
35
39
|
define_uuids
|
36
40
|
define_uuid_getter
|
41
|
+
define_uuid_setter
|
37
42
|
define_scope
|
38
43
|
end
|
39
44
|
|
@@ -50,6 +55,11 @@ module Uuids
|
|
50
55
|
class_eval "def uuid; uuids.map(&:value).sort.first; end"
|
51
56
|
end
|
52
57
|
|
58
|
+
# Defines the <tt>uuid=</tt> method
|
59
|
+
def define_uuid_setter
|
60
|
+
class_eval "def uuid=(value); uuids.new value: value; end"
|
61
|
+
end
|
62
|
+
|
53
63
|
# Defines the <tt>uuid</tt> relation scope.
|
54
64
|
def define_scope
|
55
65
|
scope(
|
data/lib/uuids/version.rb
CHANGED
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|