Class: Couchbase::JsonTranscoder
- Inherits:
-
Object
- Object
- Couchbase::JsonTranscoder
- Defined in:
- lib/couchbase/json_transcoder.rb,
/Users/sergey.auseyau/code/couchbase-ruby-client/lib/couchbase/json_transcoder.rb more...
Instance Method Summary collapse
-
#decode(blob, _flags) ⇒ Object
Object decoded document.
-
#encode(document) ⇒ Array<String, Integer>
Pair of encoded document and flags.
Instance Method Details
#decode(blob, _flags) ⇒ Object
Returns Object decoded document.
28 29 30 |
# File 'lib/couchbase/json_transcoder.rb', line 28 def decode(blob, _flags) JSON.parse(blob) unless blob&.empty? end |
#encode(document) ⇒ Array<String, Integer>
Returns pair of encoded document and flags.
21 22 23 |
# File 'lib/couchbase/json_transcoder.rb', line 21 def encode(document) [JSON.generate(document), (0x02 << 24) | 0x06] end |