Sha256: 2d53c428a31c1157dbb4172fb3e76276406399d35f2fd404691d6fc49b148637
Contents?: true
Size: 750 Bytes
Versions: 1
Compression:
Stored size: 750 Bytes
Contents
require 'msgpack' require 'grape' require 'grape/msgpack/version' module Grape # Message pack formatter for Grape module Msgpack class << self def call(obj, env) return obj.to_msgpack if obj.respond_to?(:to_msgpack) MessagePack.pack(obj) end end end end class << Grape::Formatter::Base FORMATTERS[:msgpack] = Grape::Msgpack end class << Grape::ErrorFormatter::Base FORMATTERS[:msgpack] = Grape::Msgpack end Grape::ContentTypes::CONTENT_TYPES[:msgpack] = 'application/x-msgpack' if defined?(Grape::Entity) class Grape::Entity def to_msgpack(options = {}) options = options.to_h if options && options.respond_to?(:to_h) MessagePack.pack(serializable_hash(options)) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
grape-msgpack-0.0.1 | lib/grape/msgpack.rb |