| a | b | |
|---|
| 0 | + | require 'rubygems' |
|---|
| 0 | + | require 'couchrest' |
|---|
| 0 | + | |
|---|
| 0 | + | class Test < CouchRest::Model |
|---|
| 0 | + | use_database CouchRest.database('http://localhost:5984/my_db') |
|---|
| 0 | + | set_default :array => [] |
|---|
| 0 | + | end |
|---|
| 0 | + | |
|---|
| 0 | + | >> n = Test.new |
|---|
| 0 | + | => {"array"=>[], "couchrest-type"=>"Test"} |
|---|
| 0 | + | >> Test.default[:array].object_id |
|---|
| 0 | + | => 13129040 |
|---|
| 0 | + | >> n['array'].object_id |
|---|
| 0 | + | => 13129040 |
|---|
| 0 | + | >> n['array'] << "Hello, kitty" |
|---|
| 0 | + | => ["Hello, kitty"] |
|---|
| 0 | + | >> Test.default[:array] |
|---|
| 0 | + | => ["Hello, kitty"] |
|---|
| 0 | + | >> n2 = Test.new |
|---|
| 0 | + | => {"array"=>["Hello, kitty"], "couchrest-type"=>"Test"} |
|---|
| ... | |
|---|