mongoid-nested-serialization 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,12 +1,2 @@
1
- require "mongoid"
2
- require "mongoid/nested_serialization/version"
3
1
  require "mongoid/nested_serialization"
4
-
5
- module Mongoid
6
- module Document
7
- def self.included(base)
8
- super
9
- base.send(:include, Mongoid::NestedSerialization)
10
- end
11
- end
12
- end
2
+ require "mongoid/nested_serialization/version"
@@ -1,3 +1,4 @@
1
+ require "mongoid/nested_serialization/core_ext"
1
2
  require "mongoid/nested_serialization/finder"
2
3
  require "mongoid/nested_serialization/serializer"
3
4
 
@@ -0,0 +1,10 @@
1
+ require "mongoid"
2
+
3
+ module Mongoid
4
+ module Document
5
+ def self.included(base)
6
+ super
7
+ base.send(:include, Mongoid::NestedSerialization)
8
+ end
9
+ end
10
+ end
@@ -3,21 +3,6 @@ require "multi_json"
3
3
  module Mongoid
4
4
  module NestedSerialization
5
5
  class Finder
6
- # parse the raw JSON data into a hash
7
- def self.parse_input(json)
8
- MultiJson.load(json)
9
- end
10
-
11
- # load the top level object directly with the collection
12
- def self.top_level_object(data)
13
- data["class_name"].constantize.find(data["id"])
14
- end
15
-
16
- # load an object nested within another, using the data
17
- def self.nested_object(object, data)
18
- object.send(data["association"]).find(data["id"])
19
- end
20
-
21
6
  def self.find(json)
22
7
  data = parse_input(json)
23
8
  # load the top level object
@@ -32,6 +17,22 @@ module Mongoid
32
17
  # once at the bottom, return the object
33
18
  object
34
19
  end
20
+
21
+ private
22
+ # parse the raw JSON data into a hash
23
+ def self.parse_input(json)
24
+ MultiJson.load(json)
25
+ end
26
+
27
+ # load the top level object directly with the collection
28
+ def self.top_level_object(data)
29
+ data["class_name"].constantize.find(data["id"])
30
+ end
31
+
32
+ # load an object nested within another, using the data
33
+ def self.nested_object(object, data)
34
+ object.send(data["association"]).find(data["id"])
35
+ end
35
36
  end
36
37
  end
37
38
  end
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module NestedSerialization
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
5
5
  end
@@ -3,10 +3,7 @@ SimpleCov.start do
3
3
  add_filter "/spec/"
4
4
  end
5
5
 
6
- require "mongoid"
7
- require "mongoid-nested-serialization"
8
-
9
- lib = File.expand_path("../../lib", __FILE__)
10
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
+ require "bundler"
7
+ Bundler.require
11
8
 
12
9
  Dir[File.join(File.dirname(__FILE__), "support/**/*.rb")].each { |f| require f }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-nested-serialization
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -124,6 +124,7 @@ files:
124
124
  - Rakefile
125
125
  - lib/mongoid-nested-serialization.rb
126
126
  - lib/mongoid/nested_serialization.rb
127
+ - lib/mongoid/nested_serialization/core_ext.rb
127
128
  - lib/mongoid/nested_serialization/finder.rb
128
129
  - lib/mongoid/nested_serialization/serializer.rb
129
130
  - lib/mongoid/nested_serialization/version.rb
@@ -151,7 +152,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
151
152
  version: '0'
152
153
  segments:
153
154
  - 0
154
- hash: -3222579037708509783
155
+ hash: -98816556624355443
155
156
  required_rubygems_version: !ruby/object:Gem::Requirement
156
157
  none: false
157
158
  requirements:
@@ -160,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
160
161
  version: '0'
161
162
  segments:
162
163
  - 0
163
- hash: -3222579037708509783
164
+ hash: -98816556624355443
164
165
  requirements: []
165
166
  rubyforge_project:
166
167
  rubygems_version: 1.8.24