Class: Couchbase::RawStringTranscoder
- Inherits:
-
Object
- Object
- Couchbase::RawStringTranscoder
- Defined in:
- lib/couchbase/raw_string_transcoder.rb,
/code/couchbase-ruby-client/lib/couchbase/raw_string_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.
35 36 37 38 39 40 |
# File 'lib/couchbase/raw_string_transcoder.rb', line 35 def decode(blob, flags) format = TranscoderFlags.decode(flags).format raise Error::DecodingFailure, "Unable to decode #{format} with the RawStringTranscoder" unless format == :string || format.nil? blob end |
#encode(document) ⇒ Array<String, Integer>
Returns pair of encoded document and flags.
24 25 26 27 28 29 30 |
# File 'lib/couchbase/raw_string_transcoder.rb', line 24 def encode(document) unless document.is_a?(String) && document.valid_encoding? raise Error::EncodingFailure, "Only String data supported by RawStringTranscoder" end [document, TranscoderFlags.new(format: :string).encode] end |