durran-mongoid 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.2.3
@@ -23,8 +23,12 @@ module Mongoid #:nodoc:
23
23
  # Builds a new Document and adds it to the association collection. The
24
24
  # document created will be of the same class as the others in the
25
25
  # association, and the attributes will be passed into the constructor.
26
+ #
27
+ # Returns the newly created object.
26
28
  def build(attributes)
27
- push(@klass.new(attributes))
29
+ object = @klass.new(attributes)
30
+ push(object)
31
+ object
28
32
  end
29
33
 
30
34
  end
data/mongoid.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mongoid}
8
- s.version = "0.2.2"
8
+ s.version = "0.2.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Durran Jordan"]
@@ -60,6 +60,12 @@ describe Mongoid::Associations::HasManyAssociation do
60
60
  @association[2].street.should == "Street 1"
61
61
  end
62
62
 
63
+ it "returns the newly built object in the association" do
64
+ address = @association.build({ :street => "Yet Another", :document_class => "Address" })
65
+ address.should be_a_kind_of(Address)
66
+ address.street.should == "Yet Another"
67
+ end
68
+
63
69
  end
64
70
 
65
71
  describe "#first" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: durran-mongoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Durran Jordan