Module: Couchbase::Transcoder::Plain

Defined in:
lib/couchbase/transcoder.rb

Class Method Summary collapse

Class Method Details

.dump(obj, flags, options = {}) ⇒ Object


97
98
99
100
101
102
# File 'lib/couchbase/transcoder.rb', line 97

def self.dump(obj, flags, options = {})
  [
    obj,
    (flags & ~Bucket::FMT_MASK) | Bucket::FMT_PLAIN
  ]
end

.load(blob, flags, options = {}) ⇒ Object


104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/couchbase/transcoder.rb', line 104

def self.load(blob, flags, options = {})
  if (flags & Bucket::FMT_MASK) == Bucket::FMT_PLAIN || options[:forced]
    blob
  else
    if Compat.enabled?
      return Compat.guess_and_load(blob, flags, options)
    else
      raise ArgumentError,
        "unexpected flags (0x%02x instead of 0x%02x)" % [flags, Bucket::FMT_PLAIN]
    end
  end
end