mongo_helper 0.0.7 → 0.0.8

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.
@@ -1,3 +1,3 @@
1
1
  module MongoHelper
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
data/lib/mongo_helper.rb CHANGED
@@ -52,6 +52,15 @@ module MongoHelper
52
52
  self.save
53
53
  end
54
54
 
55
+ def delete_embedded!(field, obj)
56
+ return false if obj.nil?
57
+ if self.find_embedded(field, obj.id)
58
+ arr = self.send field.to_sym
59
+ arr.delete_if {|el| el.id == obj.id}
60
+ end
61
+ self.save
62
+ end
63
+
55
64
  def find_embedded(field, id)
56
65
  arr = self.send field.to_sym
57
66
  arr.find {|m| m.id == id || m.id.to_s == id}
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongo_helper
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 7
10
- version: 0.0.7
9
+ - 8
10
+ version: 0.0.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Alan Graham
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-06-12 00:00:00 Z
18
+ date: 2012-06-14 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: activesupport