Sha256: e1de8e190dc322fc2672d09b6e460792d145a5bf06c8ef64184e65ac4e6a6018
Contents?: true
Size: 832 Bytes
Versions: 1
Compression:
Stored size: 832 Bytes
Contents
require 'synapses/messages/coders' require 'multi_json' module Synapses module Messages # @author Alexander Semyonov <al@semyonov.us> module Coders module_function class << self attr_accessor :coders end self.coders = {} if defined?(::MultiJson) coders['application/json'] = MultiJson end # @param [String] payload # @param [String] content_type # @return [Hash] +payload+ decoded from +content_type+ def decode(payload, content_type) coders[content_type.to_s].decode(payload) end # @param [Hash] payload # @param [String] content_type # @return [String] +payload+ encoded as +content_type+ def encode(payload, content_type) coders[content_type.to_s].encode(payload) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
synapses-0.0.1 | lib/synapses/messages/coders.rb |