class Vx::Consumer::Serializer
Constants
- Type
Public Class Methods
define(content_type, &block)
click to toggle source
# File lib/vx/consumer/serializer.rb, line 23 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/consumer/serializer.rb, line 29 def lookup(content_type) types[content_type] end
pack(content_type, body)
click to toggle source
# File lib/vx/consumer/serializer.rb, line 33 def pack(content_type, body) if fmt = lookup(content_type) fmt.pack.call(body) end end
types()
click to toggle source
# File lib/vx/consumer/serializer.rb, line 19 def types @@types end
unpack(content_type, body, model)
click to toggle source
# File lib/vx/consumer/serializer.rb, line 39 def unpack(content_type, body, model) if fmt = lookup(content_type) fmt.unpack.call(body, model) end end