dm-aspects 0.0.6 → 0.1.0
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/lib/datamapper/aspects/bson_id.rb +4 -3
- data/lib/dm-aspects/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e25821f2599a2ecebeb70601afe52cdf4c52bedc
|
4
|
+
data.tar.gz: 6a8d144c617ca551680801f71882a28a874c38a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53c1705882d2bf13871d862924b850efb199238c9a31b4629f1bac466d2cfa2d3dc4c08b110888f0de157d6607d98fefd359234b6c4ab99dab2357b46f95b111
|
7
|
+
data.tar.gz: eb90f482ca7ac5722cd849bc32111eef05b9cda42fa11a14740b178d18507607c0277b50f3325526a2e8d359778e8a94dd6a899b4e2cde7fdaa9d7d52aee7a17
|
@@ -15,11 +15,12 @@ module DataMapper
|
|
15
15
|
module BSONID
|
16
16
|
def self.included(base)
|
17
17
|
# Public: Provides the default aspect's attributes.
|
18
|
+
base.property :id, String, length: 24, key: true, default: BSON::ObjectId.new.to_s
|
18
19
|
base.property :id, String,
|
19
20
|
length: 24,
|
20
21
|
key: true,
|
21
22
|
unique: true,
|
22
|
-
default: proc {
|
23
|
+
default: proc { BSON::ObjectId.new.to_s }
|
23
24
|
|
24
25
|
# Internal: Validates that the BSON ID is a valid object id.
|
25
26
|
base.validates_with_method :id, method: :id_is_valid?
|
@@ -33,7 +34,7 @@ module DataMapper
|
|
33
34
|
#
|
34
35
|
# Returns the generation time of the BSON Object ID as a String.
|
35
36
|
def id_generation_time
|
36
|
-
|
37
|
+
BSON::ObjectId.from_string(@id).generation_time
|
37
38
|
end
|
38
39
|
|
39
40
|
# Public: Checks if the ID is a valid BSON Object ID.
|
@@ -45,7 +46,7 @@ module DataMapper
|
|
45
46
|
#
|
46
47
|
# Returns true if ID is valid, false if not.
|
47
48
|
def id_is_valid?
|
48
|
-
if
|
49
|
+
if BSON::ObjectId.legal?(@id)
|
49
50
|
true
|
50
51
|
else
|
51
52
|
[false, 'Id must be a valid BSON ObjectId']
|
data/lib/dm-aspects/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dm-aspects
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- StyleSeek Engineering Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dm-core
|