Maps between Proton types and their Ruby native language counterparts.
@private
# File lib/codec/mapping.rb, line 83 def self.for_code(code) @@by_code["#{code}"] end
Creates a new mapping.
code - the AMQP code for this type
name - the AMQP name for this type
klasses - native Ruby classes that are mapped to this AMQP type
getter - overrides the get method for the type
# File lib/codec/mapping.rb, line 39 def initialize(code, name, klasses = nil, getter = nil) @debug = (name == "bool") @code = code @name = name @@by_preferred ||= {} @@by_code ||= {} @@by_code["#{code}"] = self @@by_name ||= {} @@by_name[name] = self @@by_class ||= {} unless klasses.nil? klasses.each do |klass| raise "entry exists for #{klass}" if @@by_class.keys.include? klass @@by_class[klass] = self unless klass.nil? end end @put_method = (name + "=").intern if getter.nil? @get_method = name.intern else @get_method = getter.intern end end
# File lib/codec/mapping.rb, line 75 def get(data) data.__send__(@get_method) end
# File lib/codec/mapping.rb, line 71 def put(data, value) data.__send__(@put_method, value) end
# File lib/codec/mapping.rb, line 69 def to_s; @name; end