mm_uses_uuid 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/lib/mm_uses_uuid.rb CHANGED
@@ -40,9 +40,14 @@ module MmUsesUuid
40
40
  super(args)
41
41
  end
42
42
 
43
- def new(*args)
44
- new_object = super(*args)
45
- new_object.find_new_uuid
43
+ def new(params = {})
44
+ passed_id = params.delete(:id) || params.delete(:_id)
45
+ new_object = super(params)
46
+ if passed_id.is_a?(BSON::Binary) and passed_id.subtype == BSON::Binary::SUBTYPE_UUID
47
+ new_object.id = passed_id
48
+ else
49
+ new_object.find_new_uuid
50
+ end
46
51
  new_object
47
52
  end
48
53
 
@@ -1,3 +1,3 @@
1
1
  module MmUsesUuid
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -45,6 +45,11 @@ describe MmUsesUuid do
45
45
  @group._id.subtype.should == BSON::Binary::SUBTYPE_UUID
46
46
  end
47
47
 
48
+ it "should not set a new uuid if one as passed as a param" do
49
+ group_with_passed_id = Group.new(:_id => BSON::Binary.new("3333333333334333y333333333333333", BSON::Binary::SUBTYPE_UUID))
50
+ group_with_passed_id.id.to_s.should == "3333333333334333y333333333333333"
51
+ end
52
+
48
53
  it "should have a useful inspect method that shows the uuid string" do
49
54
  @group._id.inspect.should == "<BSON::Binary:'#{@group._id.to_s}'>"
50
55
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 2
9
- version: 0.0.2
8
+ - 3
9
+ version: 0.0.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jonathan Chambers
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-12-05 00:00:00 +00:00
17
+ date: 2011-12-11 00:00:00 +00:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -72,7 +72,6 @@ extra_rdoc_files: []
72
72
 
73
73
  files:
74
74
  - .gitignore
75
- - .project
76
75
  - Gemfile
77
76
  - MIT-LICENSE
78
77
  - README.md
data/.project DELETED
@@ -1,18 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <projectDescription>
3
- <name>mm_uses_uuid</name>
4
- <comment></comment>
5
- <projects>
6
- </projects>
7
- <buildSpec>
8
- <buildCommand>
9
- <name>com.aptana.ide.core.unifiedBuilder</name>
10
- <arguments>
11
- </arguments>
12
- </buildCommand>
13
- </buildSpec>
14
- <natures>
15
- <nature>com.aptana.ruby.core.rubynature</nature>
16
- <nature>com.aptana.projects.webnature</nature>
17
- </natures>
18
- </projectDescription>