tinymongo 0.1.6 → 0.1.7

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.1.6
1
+ 0.1.7
@@ -1,6 +1,42 @@
1
1
  module TinyMongo
2
2
  module Helper
3
3
  class << self
4
+ def deep_copy_hash(hash)
5
+ new_hash = {}
6
+ hash.each_pair do |key, obj|
7
+ new_hash[key] = if(obj.instance_of? Hash)
8
+ deep_copy_hash(obj)
9
+ elsif(obj.instance_of? Array)
10
+ deep_copy_array(obj)
11
+ else
12
+ begin
13
+ obj.dup
14
+ rescue
15
+ obj
16
+ end
17
+ end
18
+ end
19
+ new_hash
20
+ end
21
+
22
+ def deep_copy_array(array)
23
+ new_array = []
24
+ array.each do |obj|
25
+ new_array << if(obj.instance_of? Hash)
26
+ deep_copy_hash(obj)
27
+ elsif(obj.instance_of? Array)
28
+ deep_copy_array(obj)
29
+ else
30
+ begin
31
+ obj.dup
32
+ rescue
33
+ obj
34
+ end
35
+ end
36
+ end
37
+ new_array
38
+ end
39
+
4
40
  def stringify_keys_in_hash(hash)
5
41
  new_hash = {}
6
42
  hash.each_pair { |key, value| new_hash[key.to_s] = value }
@@ -88,7 +88,7 @@ module TinyMongo
88
88
  end
89
89
 
90
90
  def initialize(hash={})
91
- @_tinymongo_hash = (self.class.instance_variable_get(:@_tinymongo_defaults).merge(Helper.stringify_keys_in_hash(hash)) || {}) if hash
91
+ @_tinymongo_hash = (Helper.deep_copy_hash(self.class.instance_variable_get(:@_tinymongo_defaults)).merge(Helper.stringify_keys_in_hash(hash)) || {}) if hash
92
92
  end
93
93
 
94
94
  def _id
data/tinymongo.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{tinymongo}
8
- s.version = "0.1.6"
8
+ s.version = "0.1.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Peter Jihoon Kim"]
12
- s.date = %q{2010-07-27}
12
+ s.date = %q{2010-07-28}
13
13
  s.description = %q{Simple MongoDB wrapper}
14
14
  s.email = %q{raingrove@gmail.com}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 6
9
- version: 0.1.6
8
+ - 7
9
+ version: 0.1.7
10
10
  platform: ruby
11
11
  authors:
12
12
  - Peter Jihoon Kim
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-07-27 00:00:00 +09:00
17
+ date: 2010-07-28 00:00:00 +09:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency