tinymongo 0.1.0 → 0.1.1

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/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ pkg
5
+ doc
data/README.rdoc CHANGED
@@ -26,19 +26,19 @@ To create TinyMongo config file (config/tinymongo.yml), do the following:
26
26
  mongo_key :children
27
27
 
28
28
  def make_child
29
- child = Person.new(:name => 'Baby', :age => 0)
30
-
31
- self.push({:children => child})
29
+ child = Person.create(:name => 'Baby', :age => 0)
30
+ push({:children => child})
32
31
  end
33
32
 
34
33
  def grow_up
35
- self.inc({:age => 1})
34
+ inc({:age => 1})
36
35
  end
37
36
 
38
37
  def set_stuff(n,a,c)
39
- name = n
40
- age = a
41
- children = c
38
+ # don't forget to put self
39
+ self.name = n
40
+ self.age = a
41
+ self.children = c
42
42
  save
43
43
  end
44
44
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -61,14 +61,18 @@ module TinyMongo
61
61
  collection.remove({ '_id' => Helper.bson_object_id(id)})
62
62
  end
63
63
 
64
- def delete_all
64
+ def drop
65
65
  collection.drop
66
66
  end
67
+
68
+ def delete_all
69
+ drop
70
+ end
67
71
 
68
72
  def destroy_all
69
- delete_all
73
+ drop
70
74
  end
71
-
75
+
72
76
  def count
73
77
  collection.count
74
78
  end
@@ -98,23 +102,13 @@ module TinyMongo
98
102
  @_tinymongo_hash.clone
99
103
  end
100
104
 
101
- def save(v=true)
102
-
103
- if((v && (defined?(Rails) && self.valid?) || (!defined?(Rails))) || (!v))
104
- begin
105
- obj = create_or_update
106
- return obj
107
- rescue
108
- return false
109
- end
110
- else
111
- return false
112
- end
105
+ def save
106
+ return create_or_update
113
107
  end
114
108
 
115
109
  def update_attribute(name, value)
116
110
  send(name.to_s + '=', value)
117
- save(false)
111
+ save
118
112
  end
119
113
 
120
114
  def update_attributes(hash)
@@ -265,7 +259,9 @@ module TinyMongo
265
259
  protected
266
260
  def create_or_update
267
261
  if(@_tinymongo_hash['_id'].nil?) # new
268
- @_tinymongo_hash['_id'] = collection.save(@_tinymongo_hash)
262
+ oid = collection.save(@_tinymongo_hash)
263
+ @_tinymongo_hash.delete(:_id)
264
+ @_tinymongo_hash['_id'] = oid
269
265
  else # update
270
266
  collection.update({ '_id' => @_tinymongo_hash['_id'] }, @_tinymongo_hash)
271
267
  end
data/tinymongo.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{tinymongo}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
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"]
@@ -17,7 +17,8 @@ Gem::Specification.new do |s|
17
17
  "README.rdoc"
18
18
  ]
19
19
  s.files = [
20
- "LICENSE",
20
+ ".gitignore",
21
+ "LICENSE",
21
22
  "README.rdoc",
22
23
  "Rakefile",
23
24
  "VERSION",
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 0
9
- version: 0.1.0
8
+ - 1
9
+ version: 0.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Peter Jihoon Kim
@@ -53,6 +53,7 @@ extra_rdoc_files:
53
53
  - LICENSE
54
54
  - README.rdoc
55
55
  files:
56
+ - .gitignore
56
57
  - LICENSE
57
58
  - README.rdoc
58
59
  - Rakefile