Module: JOffice::Redis::MarshalValue

Defined in:
lib/joffice_redis/marshal.rb

Class Method Summary collapse

Class Method Details

.box_boolean(value) ⇒ Object



59
60
61
# File 'lib/joffice_redis/marshal.rb', line 59

def box_boolean(value)
  value ? '1' : '0'
end

.box_integer(value) ⇒ Object



49
50
51
# File 'lib/joffice_redis/marshal.rb', line 49

def box_integer(value)
  value ? value.to_s : '0'
end

.box_object(value) ⇒ Object



29
30
31
# File 'lib/joffice_redis/marshal.rb', line 29

def box_object(value)
  value.blank? ? value : Marshal.dump(value)
end

.box_string(value) ⇒ Object



39
40
41
# File 'lib/joffice_redis/marshal.rb', line 39

def box_string(value)
 (value || '').to_s.to_msgpack
end

.unbox_boolean(value) ⇒ Object



54
55
56
# File 'lib/joffice_redis/marshal.rb', line 54

def unbox_boolean(value)
  '1' == value
end

.unbox_integer(value) ⇒ Object



44
45
46
# File 'lib/joffice_redis/marshal.rb', line 44

def unbox_integer(value)
  value.to_i
end

.unbox_object(value) ⇒ Object



24
25
26
# File 'lib/joffice_redis/marshal.rb', line 24

def unbox_object(value)
  value.blank? ? value : Marshal.load(value)
end

.unbox_string(value) ⇒ Object



34
35
36
# File 'lib/joffice_redis/marshal.rb', line 34

def unbox_string(value)
  value.blank? ? '' : MessagePack.unpack(value).encode2utf8
end