hashrocket-mongomapper 0.3.8 → 0.3.10

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.8
1
+ 0.3.10
@@ -9,11 +9,7 @@ module MongoMapper
9
9
  def build(opts={})
10
10
  owner = @owner
11
11
  child = @association.klass.new(opts)
12
- child.class_eval do
13
- define_method(owner.class.name.underscore) do
14
- owner
15
- end
16
- end
12
+ assign_parent_reference(child)
17
13
  child._parent_document = owner
18
14
  self << child
19
15
  child
@@ -26,14 +22,7 @@ module MongoMapper
26
22
  when String
27
23
  if load_target
28
24
  child = @target.detect {|item| item.id == opts}
29
- if child
30
- owner = @owner
31
- child.class_eval do
32
- define_method(owner.class.name.underscore) do
33
- owner
34
- end
35
- end
36
- end
25
+ assign_parent_reference(child)
37
26
  child
38
27
  end
39
28
  end
@@ -54,9 +43,25 @@ module MongoMapper
54
43
  protected
55
44
  def find_target
56
45
  (@_values || []).map do |e|
57
- @association.klass.new(e)
46
+ child = @association.klass.new(e)
47
+ assign_parent_reference(child)
48
+ child
58
49
  end
59
50
  end
51
+
52
+ private
53
+
54
+ def assign_parent_reference(child)
55
+ return unless child && @owner
56
+ return if @owner.class.name.blank?
57
+ owner = @owner
58
+ child.class_eval do
59
+ define_method(owner.class.name.underscore) do
60
+ owner
61
+ end
62
+ end
63
+ end
64
+
60
65
  end
61
66
  end
62
67
  end
data/mongomapper.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mongomapper}
8
- s.version = "0.3.8"
8
+ s.version = "0.3.10"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["John Nunemaker"]
12
- s.date = %q{2009-09-05}
12
+ s.date = %q{2009-09-10}
13
13
  s.default_executable = %q{mmconsole}
14
14
  s.email = %q{nunemaker@gmail.com}
15
15
  s.executables = ["mmconsole"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hashrocket-mongomapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.8
4
+ version: 0.3.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nunemaker
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-05 00:00:00 -07:00
12
+ date: 2009-09-10 00:00:00 -07:00
13
13
  default_executable: mmconsole
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -135,7 +135,6 @@ files:
135
135
  - test/unit/test_validations.rb
136
136
  has_rdoc: false
137
137
  homepage: http://github.com/jnunemaker/mongomapper
138
- licenses:
139
138
  post_install_message:
140
139
  rdoc_options:
141
140
  - --charset=UTF-8
@@ -156,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
155
  requirements: []
157
156
 
158
157
  rubyforge_project: mongomapper
159
- rubygems_version: 1.3.5
158
+ rubygems_version: 1.2.0
160
159
  signing_key:
161
160
  specification_version: 3
162
161
  summary: Awesome gem for modeling your domain and storing it in mongo