Sha256: cbbfba4bc514fae58296ea6b997548c961c695d7a4f9d11b89399a0f4476a059

Contents?: true

Size: 615 Bytes

Versions: 7

Compression:

Stored size: 615 Bytes

Contents

module Zencoder
  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

7 entries across 7 versions & 1 rubygems

Version Path
zencoder-2.5.1 lib/zencoder/serializer.rb
zencoder-2.5.0 lib/zencoder/serializer.rb
zencoder-2.4.6 lib/zencoder/serializer.rb
zencoder-2.4.5 lib/zencoder/serializer.rb
zencoder-2.4.4 lib/zencoder/serializer.rb
zencoder-2.4.3 lib/zencoder/serializer.rb
zencoder-2.4.2 lib/zencoder/serializer.rb