uuids 1.0.2 → 1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 260cc30e4e91f5e3345123e05e24251ef71775da
4
- data.tar.gz: 617fa0d617c50c1f06f837374fb22948483173ce
3
+ metadata.gz: 90ebf6afbe59d579cfd3529c5ba780219a1267ba
4
+ data.tar.gz: d4468af5f78da1e7ae760019e1dc59f48fa648dc
5
5
  SHA512:
6
- metadata.gz: fd25b5dbeb1702b2b1f0e8f75fc3e7969fac3ec9219def9a7db3529b5f00ff00284bd1e5998177b08210269ff91d304f05da6142977040d75811ddcd9f9f6cf2
7
- data.tar.gz: cf5f4e1e0761b468a3b9c994b8c713cc53b0bf8c19c1ccd1df64ea53a6d68ce7bb0ee56c08aa6fedae67e1711add1bfb954f262222df0eac7a0bcb379b33270f
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.new
107
- city.save!
106
+ city = City.create!
107
+ city.uuid.nil?
108
+ # => false
108
109
 
109
110
  # UUID is assigned manually
110
- city = City.new
111
- city.uuids.new value: "6d9456a9-8f54-4ff7-ba0d-9854f1954417"
112
- city.save
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
@@ -2,5 +2,5 @@
2
2
  module Uuids
3
3
 
4
4
  # Current release.
5
- VERSION = "1.0.2"
5
+ VERSION = "1.1"
6
6
  end
Binary file