Module: Couchbase::Transcoder::Compat

Defined in:
lib/couchbase/transcoder.rb

Class Method Summary collapse

Class Method Details

.disable!Object


30
31
32
# File 'lib/couchbase/transcoder.rb', line 30

def self.disable!
  @disabled = true
end

.enable!Object


26
27
28
# File 'lib/couchbase/transcoder.rb', line 26

def self.enable!
  @disabled = false
end

.enabled?Boolean

Returns:

  • (Boolean)

34
35
36
# File 'lib/couchbase/transcoder.rb', line 34

def self.enabled?
  !@disabled
end

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


38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/couchbase/transcoder.rb', line 38

def self.guess_and_load(blob, flags, options = {})
  case flags & Bucket::FMT_MASK
  when Bucket::FMT_DOCUMENT
    MultiJson.load(blob)
  when Bucket::FMT_MARSHAL
    ::Marshal.load(blob)
  when Bucket::FMT_PLAIN
    blob
  else
    raise ArgumentError, "unexpected flags (0x%02x)" % flags
  end
end