Class: Couchbase::Collection::LookupInResult
- Inherits:
-
Object
- Object
- Couchbase::Collection::LookupInResult
- Defined in:
- lib/couchbase/collection_options.rb,
/Users/sergey.auseyau/code/couchbase-ruby-client/lib/couchbase/collection_options.rb more...
Direct Known Subclasses
Instance Attribute Summary collapse
-
#cas ⇒ Integer
Holds the CAS value of the fetched document.
-
#encoded ⇒ Array<SubDocumentField>
Holds the encoded subdocument responses.
-
#transcoder ⇒ JsonTranscoder
The default transcoder which should be used.
Instance Method Summary collapse
-
#content(path_or_index, transcoder = self.transcoder) ⇒ Object
Decodes the content at the given index (or path).
-
#exists?(path_or_index) ⇒ Boolean
Allows to check if a value at the given index exists.
-
#initialize {|self| ... } ⇒ LookupInResult
constructor
A new instance of LookupInResult.
Constructor Details
#initialize {|self| ... } ⇒ LookupInResult
Returns a new instance of LookupInResult.
203 204 205 206 |
# File 'lib/couchbase/collection_options.rb', line 203 def initialize @deleted = false yield self if block_given? end |
Instance Attribute Details
#cas ⇒ Integer
Returns holds the CAS value of the fetched document.
161 162 163 |
# File 'lib/couchbase/collection_options.rb', line 161 def cas @cas end |
#encoded ⇒ Array<SubDocumentField>
Returns holds the encoded subdocument responses.
200 201 202 |
# File 'lib/couchbase/collection_options.rb', line 200 def encoded @encoded end |
#transcoder ⇒ JsonTranscoder
Returns The default transcoder which should be used.
209 210 211 |
# File 'lib/couchbase/collection_options.rb', line 209 def transcoder @transcoder end |
Instance Method Details
#content(path_or_index, transcoder = self.transcoder) ⇒ Object
Decodes the content at the given index (or path)
168 169 170 171 172 173 174 175 |
# File 'lib/couchbase/collection_options.rb', line 168 def content(path_or_index, transcoder = self.transcoder) field = get_field_at_index(path_or_index) raise field.error unless field.error.nil? raise Error::PathNotFound, "Path is not found: #{path_or_index}" unless field.exists transcoder.decode(field.value, :json) end |
#exists?(path_or_index) ⇒ Boolean
Allows to check if a value at the given index exists
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/couchbase/collection_options.rb', line 182 def exists?(path_or_index) field = case path_or_index when String encoded.find { |f| f.path == path_or_index } else return false unless path_or_index >= 0 && path_or_index < encoded.size encoded[path_or_index] end return false unless field raise field.error unless field.error.nil? field.exists end |