class Vx::Common::AMQP::Formatter

Public Class Methods

define(content_type, &block) click to toggle source
# File lib/vx/common/amqp/formatter.rb, line 38
def define(content_type, &block)
  fmt = Format.new content_type
  fmt.instance_eval(&block)
  formats.merge! content_type => fmt
end
formats() click to toggle source
# File lib/vx/common/amqp/formatter.rb, line 34
def formats
  @@formats
end
lookup(content_type) click to toggle source
# File lib/vx/common/amqp/formatter.rb, line 44
def lookup(content_type)
  formats[content_type]
end
pack(content_type, body) click to toggle source
# File lib/vx/common/amqp/formatter.rb, line 48
def pack(content_type, body)
  if fmt = lookup(content_type)
    fmt.pack.call(body)
  end
end
unpack(content_type, model, body) click to toggle source
# File lib/vx/common/amqp/formatter.rb, line 54
def unpack(content_type, model, body)
  if fmt = lookup(content_type)
    fmt.unpack.call(body, model)
  end
end