Class: Couchbase::RawBinaryTranscoder
- Inherits:
-
Object
- Object
- Couchbase::RawBinaryTranscoder
- Defined in:
- lib/couchbase/raw_binary_transcoder.rb,
/code/couchbase-ruby-client/lib/couchbase/raw_binary_transcoder.rb
Instance Method Summary collapse
-
#decode(blob, flags) ⇒ String
Decoded document.
-
#encode(document) ⇒ Array<String, Integer>
Pair of encoded document and flags.
Instance Method Details
#decode(blob, flags) ⇒ String
Returns decoded document.
32 33 34 35 36 37 |
# File 'lib/couchbase/raw_binary_transcoder.rb', line 32 def decode(blob, flags) format = TranscoderFlags.decode(flags).format raise Error::DecodingFailure, "Unable to decode #{format} with the RawBinaryTranscoder" unless format == :binary || format.nil? blob end |
#encode(document) ⇒ Array<String, Integer>
Returns pair of encoded document and flags.
23 24 25 26 27 |
# File 'lib/couchbase/raw_binary_transcoder.rb', line 23 def encode(document) raise Error::EncodingFailure, "Only binary data supported by RawBinaryTranscoder" unless document.is_a?(String) [document, TranscoderFlags.new(format: :binary).encode] end |