dm-aspects 0.0.3 → 0.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 76edcbc7c99910f52334bb2a686fca0346c68156
4
- data.tar.gz: 79f3f4292a74babff405e208ce23a4dfb76de132
3
+ metadata.gz: 19d6a6eef086183c567938fcb7d963be0990ea05
4
+ data.tar.gz: b83bd9acf7e9e998638a39049f682be85c81fa56
5
5
  SHA512:
6
- metadata.gz: 3b7f4abd012ffe1d8fd88118e0bf9d1aeeac4ea74c614c41a4c4ce3451e2fecd3f34082360831bc940be77b4f45592018661ef5a3fabf8fcc7f87b348765c723
7
- data.tar.gz: f4ecb216fcb3df27be1675e3b2a7281a4e84f8b3ceeca65259ec671a692bbb3b39d486c4b0f8afffa49346b9caf3b5b7e731d8f8657ba627fc25dcf258385497
6
+ metadata.gz: fe5f27486d39cf40804f6c678b59f241009be964b09b0138795256014feafab666a51c585767f4e64448b9cc5b2660dd707b489f5bf03f4f04515307a8bd9644
7
+ data.tar.gz: 39609270d6e706a806e49fc04a0e1bf98b64eb5e3a0e7f03a510c3af3c7de31badd19f7ac0d5632b0076ec3699a4cdcb3d9bcd8bbae7b8ce5e461b3d8c03070b
data/Rakefile CHANGED
@@ -13,4 +13,5 @@ Rake::TestTask.new do |t|
13
13
  t.libs << "spec"
14
14
  t.pattern = "spec/**/*_spec.rb"
15
15
  end
16
+
16
17
  task :default => [:test]
@@ -2,17 +2,46 @@
2
2
 
3
3
  module DataMapper
4
4
  module Aspects
5
+ # Public: Provides a valid BSON Object ID key property.
6
+ # Also validates that BSON IDs are valid object ids.
7
+ #
8
+ # Examples
9
+ #
10
+ # my_obj.id.id_is_valid?
11
+ # # => true
12
+ #
13
+ # my_obj.id.id_generation_time
14
+ # # => 2014-05-09 06:07:00 UTC
5
15
  module BSONID
6
16
  def self.included(base)
17
+ # Public: Provides the default aspect's attributes.
7
18
  base.property :id, String, length: 24, key: true, default: Moped::BSON::ObjectId.new.to_s
19
+
20
+ # Internal: Validates that the BSON ID is a valid object id.
8
21
  base.validates_with_method :id, method: :id_is_valid?
9
22
 
23
+ # Public: Retrieves the generation time of the BSON Object ID.
24
+ #
25
+ # Examples
26
+ #
27
+ # id_generation_time()
28
+ # # => 2014-05-09 06:07:00 UTC
29
+ #
30
+ # Returns the generation time of the BSON Object ID as a String.
10
31
  def id_generation_time
11
32
  Moped::BSON::ObjectId.from_string(@id).generation_time
12
33
  end
13
34
 
35
+ # Public: Checks if the ID is a valid BSON Object ID.
36
+ #
37
+ # Examples
38
+ #
39
+ # id_is_valid?()
40
+ # # => true
41
+ #
42
+ # Returns true if ID is valid, false if not.
14
43
  def id_is_valid?
15
- Moped::BSON::Objectid.legal?(@id)
44
+ Moped::BSON::ObjectId.legal?(@id)
16
45
  end
17
46
  end
18
47
  end
@@ -1,5 +1,5 @@
1
1
  module DataMapper
2
2
  module Aspects
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dm-aspects
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - StyleSeek Engineering Team