mongo_mapper-unstable 2010.07.08 → 2010.07.09

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.
Files changed (2) hide show
  1. data/examples/modifiers/set.rb +25 -0
  2. metadata +4 -3
@@ -0,0 +1,25 @@
1
+ $LOAD_PATH.unshift(File.expand_path('../../../lib', __FILE__))
2
+ require 'mongo_mapper'
3
+ require 'pp'
4
+
5
+ MongoMapper.database = 'testing'
6
+
7
+ class User
8
+ include MongoMapper::Document
9
+
10
+ key :name, String
11
+ key :tags, Array
12
+ end
13
+ User.collection.remove # empties collection
14
+
15
+ john = User.create(:name => 'John', :tags => %w[ruby mongo], :age => 28)
16
+ bill = User.create(:name => 'Bill', :tags => %w[ruby mongo], :age => 30)
17
+
18
+ User.set({:name => 'John'}, :tags => %[ruby])
19
+ pp john.reload
20
+
21
+ User.set(john.id, :tags => %w[ruby mongo])
22
+ pp john.reload
23
+
24
+ john.set(:tags => %w[something different])
25
+ pp john.reload
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 2010
7
7
  - 7
8
- - 8
9
- version: 2010.07.08
8
+ - 9
9
+ version: 2010.07.09
10
10
  platform: ruby
11
11
  authors:
12
12
  - John Nunemaker
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-07-08 00:00:00 -05:00
17
+ date: 2010-07-09 00:00:00 -05:00
18
18
  default_executable: mmconsole
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -141,6 +141,7 @@ extra_rdoc_files: []
141
141
  files:
142
142
  - bin/mmconsole
143
143
  - examples/keys.rb
144
+ - examples/modifiers/set.rb
144
145
  - examples/scopes.rb
145
146
  - examples/querying.rb
146
147
  - examples/plugins.rb