Sha256: 9634e5d2ba2a6c8e970d47d6686c75e11b1db0509c3cf0fd458680245862a504

Contents?: true

Size: 594 Bytes

Versions: 4

Compression:

Stored size: 594 Bytes

Contents

$LOAD_PATH.unshift(File.expand_path('../../../lib', __FILE__))
require 'mongo_mapper'
require 'pp'

MongoMapper.database = 'testing'

class User
  include MongoMapper::Document

  key :name, String
  key :tags, Array
end
User.collection.remove # empties collection

john = User.create(:name => 'John',  :tags => %w[ruby mongo], :age => 28)
bill = User.create(:name => 'Bill',  :tags => %w[ruby mongo], :age => 30)

User.set({:name => 'John'}, :tags => %[ruby])
pp john.reload

User.set(john.id, :tags => %w[ruby mongo])
pp john.reload

john.set(:tags => %w[something different])
pp john.reload

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mongo_mapper-0.14.0 examples/modifiers/set.rb
mongo_mapper-0.14.0.rc1 examples/modifiers/set.rb
mongo_mapper-0.13.1 examples/modifiers/set.rb
mongo_mapper-0.13.0 examples/modifiers/set.rb