Class: Couchbase::Document
- Inherits:
-
Object
- Object
- Couchbase::Document
- Extended by:
- Forwardable
- Defined in:
- lib/couchbase/document.rb
Instance Attribute Summary collapse
-
#cas ⇒ Object
readonly
Returns the value of attribute cas.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#ttl ⇒ Object
readonly
Returns the value of attribute ttl.
Instance Method Summary collapse
- #data ⇒ Object (also: #to_a, #to_h, #to_hash)
-
#initialize(java_doc) ⇒ Document
constructor
A new instance of Document.
- #to_s ⇒ Object
Constructor Details
#initialize(java_doc) ⇒ Document
Returns a new instance of Document.
9 10 11 12 13 14 15 |
# File 'lib/couchbase/document.rb', line 9 def initialize(java_doc) @id = java_doc.id @cas = java_doc.cas @ttl = java_doc.expiry @content = java_doc.content @data = nil end |
Instance Attribute Details
#cas ⇒ Object (readonly)
Returns the value of attribute cas.
7 8 9 |
# File 'lib/couchbase/document.rb', line 7 def cas @cas end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
7 8 9 |
# File 'lib/couchbase/document.rb', line 7 def content @content end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/couchbase/document.rb', line 7 def id @id end |
#ttl ⇒ Object (readonly)
Returns the value of attribute ttl.
7 8 9 |
# File 'lib/couchbase/document.rb', line 7 def ttl @ttl end |
Instance Method Details
#data ⇒ Object Also known as: to_a, to_h, to_hash
21 22 23 24 25 26 27 |
# File 'lib/couchbase/document.rb', line 21 def data @data ||= begin MultiJson.load(@content) rescue MultiJson::ParseError # TODO: figure out what to do here... end end |
#to_s ⇒ Object
17 18 19 |
# File 'lib/couchbase/document.rb', line 17 def to_s @content end |