mongoid-embedded_copy 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d7c96aa95743c9b0ce42fe49cb82fb0b2a906f63
4
- data.tar.gz: 5c32ab4b11fa8a0c1cb8bfb4e9c5af1a6fb88697
3
+ metadata.gz: 7072bf2f0505119bffa05338cffdee1f557a808e
4
+ data.tar.gz: 3fb24208017739ca2c6cb3820ca6af758951ea62
5
5
  SHA512:
6
- metadata.gz: 6a8d8bdf66cf2cd8b5bc0e9fd46eb2b4a25a8ef4ab3f54a1cf15e279182e2f803b157d852f4b7ba7c2486e4271b213a19f3e716ce2bf73779ad536449a314b99
7
- data.tar.gz: e887b5ccbf3979d8d0700d863f436b0a4dbe0290c331930ecd7649f0d18f01fed71642914a78c77c496a09fa601ab0bc05e237d1876f03182961f246c65cf135
6
+ metadata.gz: ae7a9ae7a35e68a584ccb61a78b1326292eea0c460d4e52216a8ab5c81298abcdac95de0a0a2083fd9fd50f6752184b9a8404ad4093360093e7fd24d736c15f2
7
+ data.tar.gz: a5e541795750ba55fa8b9b05df5adfdbb3477d93e0d81f78ed9d40628977dfed96b77bc00b06ee4e76aa26330589c69bcc33327bdbe6c8ee4f5b177375c3fac9
@@ -1,6 +1,6 @@
1
1
  module Mongoid
2
2
  module EmbeddedCopy
3
- VERSION = '1.0.0'
3
+ VERSION = '1.0.1'
4
4
  end
5
5
  end
6
6
 
@@ -67,7 +67,7 @@ module Mongoid
67
67
  embedded_in embed_name, embed_opts
68
68
 
69
69
  klass.fields.each do |name, f|
70
- next if skipped.include?(name) || name == '_id'
70
+ next if skipped.include?(name) || name == '_id' || f.metadata
71
71
  options = f.options.dup
72
72
  options.delete(:klass)
73
73
  field name, options
@@ -80,6 +80,13 @@ module Mongoid
80
80
  alias_method_chain "#{name}=", :update_original
81
81
  end
82
82
  end
83
+
84
+ klass.relations.each do |name, rel|
85
+ next if skipped.include?(name)
86
+ options = rel.relation.valid_options +
87
+ Mongoid::Relations::Options::COMMON
88
+ public_send(rel.macro, name, rel.to_h.slice(options))
89
+ end
83
90
  end
84
91
 
85
92
  def load_original
@@ -87,13 +94,10 @@ module Mongoid
87
94
  end
88
95
  end
89
96
 
90
- if klass.const_defined?(embedded_class)
91
- klass.const_get(embedded_class).send(:include, document_module)
92
- else
93
- klass.const_set(embedded_class, Class.new do
94
- include document_module
95
- end)
97
+ if !klass.const_defined?(embedded_class)
98
+ klass.const_set(embedded_class, Class.new)
96
99
  end
100
+ klass.const_get(embedded_class).send(:include, document_module)
97
101
  end
98
102
 
99
103
  def self.equality_module_for(klass)
data/test/test_helper.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require 'bundler/setup'
2
2
  require 'simplecov'
3
- require 'pry'
4
3
  SimpleCov.configure do
5
4
  add_filter '/test/'
6
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-embedded_copy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geoffroy Planquart
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-09 00:00:00.000000000 Z
11
+ date: 2015-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid
@@ -84,6 +84,6 @@ test_files:
84
84
  - test/models/user.rb
85
85
  - test/models/post.rb
86
86
  - test/mongoid.yml
87
- - test/test_helper.rb
88
87
  - test/embedded_copy_test.rb
88
+ - test/test_helper.rb
89
89
  has_rdoc: