class RiakJson::Document
Implements the RiakJson::Collection
api (.key, .to_json_document) to easily store documents in a RiakJson::Collection
Attributes
attributes[RW]
body[RW]
key[RW]
Public Class Methods
new(key=nil, body={})
click to toggle source
# File lib/riak_json/document.rb, line 29 def initialize(key=nil, body={}) @key = key @body = body end
Public Instance Methods
[](key)
click to toggle source
# File lib/riak_json/document.rb, line 34 def [](key) @body[key] end
[]=(key, value)
click to toggle source
# File lib/riak_json/document.rb, line 38 def []=(key, value) @body[key] = value end
to_json()
click to toggle source
Returns a JSON string representation
# File lib/riak_json/document.rb, line 43 def to_json self.body.to_json end
to_json_document()
click to toggle source
Returns a JSON string representation. Invoked by RiakJson::Collection
to serialize an object for writing to RiakJson
# File lib/riak_json/document.rb, line 50 def to_json_document self.to_json end