Sha256: 5c8d1d1021c177f3034f57808d306c3513ffbcbec484ca96e10c923dee7846bb

Contents?: true

Size: 610 Bytes

Versions: 1

Compression:

Stored size: 610 Bytes

Contents

module Xio
  module Serializer

    extend self

    def self.included(klass)
      klass.extend(self)
    end

    def encode(content)
      if content.is_a?(String) || content.nil?
        content
      else
        if MultiJson.respond_to?(:dump)
          MultiJson.dump(content)
        else
          MultiJson.encode(content)
        end
      end
    end

    def decode(content)
      if content.is_a?(String)
        if MultiJson.respond_to?(:dump)
          MultiJson.load(content)
        else
          MultiJson.decode(content)
        end
      else
        content
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
xio-1.0.0 lib/xio/serializer.rb