Sha256: bffc27d57cacfee27697d403da19a54d0ccbabb87f1af76726344e430f7c35b3
Contents?: true
Size: 1.62 KB
Versions: 1
Compression:
Stored size: 1.62 KB
Contents
#encoding: utf-8 =begin Copyright 2010 Denis Kokorin <virkdi@mail.ru> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. =end require 'msgpack' module JOffice::Redis module MarshalValue def unbox_object(value) value.blank? ? value : Marshal.load(value) end module_function :unbox_object def box_object(value) value.blank? ? value : Marshal.dump(value) end module_function :box_object def unbox_string(value) value.blank? ? '' : MessagePack.unpack(value).encode2utf8 end module_function :unbox_string def box_string(value) (value || '').to_s.to_msgpack end module_function :box_string def unbox_integer(value) value.to_i end module_function :unbox_integer def box_integer(value) value ? value.to_s : '0' end module_function :box_integer def unbox_boolean(value) '1' == value end module_function :unbox_boolean def box_boolean(value) value ? '1' : '0' end module_function :box_boolean end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
joffice_redis-0.1.1 | lib/joffice_redis/marshal.rb |