Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/types/hash.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.proton_data_get(data) ⇒ Object

Raises:

  • (TypeError)


58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/types/hash.rb', line 58

def proton_data_get(data)
  raise TypeError, "data object cannot be nil" if data.nil?

  type = data.type

  raise TypeError, "element is not a map" unless type == Qpid::Proton::Codec::MAP

  count = data.map
  result = {}

  data.enter

  (0...(count/2)).each do
    data.next
    type = data.type
    key = type.get(data)
    data.next
    type = data.type
    value = type.get(data)
    result[key] = value
  end

  data.exit

  return result
end

Instance Method Details

#proton_data_put(data) ⇒ Object

Places the contents of the hash into the specified data object.

Arguments

  • data - the Qpid::Proton::Data instance

Examples

data = Qpid::Proton::Data.new
values = {:foo => :bar}
values.proton_data_put(data)

Raises:

  • (TypeError)


40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/types/hash.rb', line 40

def proton_data_put(data)
  raise TypeError, "data object cannot be nil" if data.nil?

  data.put_map
  data.enter

  each_pair do |key, value|
    type = Qpid::Proton::Codec::Mapping.for_class(key.class)
    type.put(data, key)
    type = Qpid::Proton::Codec::Mapping.for_class(value.class)
    type.put(data, value)
  end

  data.exit
end