Revision 03341deff38e () - Diff

Link to this snippet: https://friendpaste.com/2YBebSb8eQYVfMkPo94sEe
Embed:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
require 'rubygems'
require 'couchrest'

class Test < CouchRest::Model
use_database CouchRest.database('http://localhost:5984/my_db')
set_default :array => []
end

>> n = Test.new
=> {"array"=>[], "couchrest-type"=>"Test"}
>> Test.default[:array].object_id
=> 13129040
>> n['array'].object_id
=> 13129040
>> n['array'] << "Hello, kitty"
=> ["Hello, kitty"]
>> Test.default[:array]
=> ["Hello, kitty"]
>> n2 = Test.new
=> {"array"=>["Hello, kitty"], "couchrest-type"=>"Test"}