class Vx::Lib::Consumer::Serializer
Constants
- Type
Public Class Methods
define(content_type, &block)
click to toggle source
# File lib/vx/lib/consumer/serializer.rb, line 26 def define(content_type, &block) fmt = Type.new content_type fmt.instance_eval(&block) types.merge! content_type => fmt end
lookup(content_type)
click to toggle source
# File lib/vx/lib/consumer/serializer.rb, line 32 def lookup(content_type) types[content_type] end
pack(content_type, body)
click to toggle source
# File lib/vx/lib/consumer/serializer.rb, line 36 def pack(content_type, body) if fmt = lookup(content_type) fmt.pack.call(body) else body end end
types()
click to toggle source
# File lib/vx/lib/consumer/serializer.rb, line 22 def types @@types end
unpack(content_type, body, model)
click to toggle source
# File lib/vx/lib/consumer/serializer.rb, line 44 def unpack(content_type, body, model) if fmt = lookup(content_type) fmt.unpack.call(body, model) end end