lib/protobuf/descriptor/enum_descriptor.rb in ruby_protobuf-0.3.3 vs lib/protobuf/descriptor/enum_descriptor.rb in ruby_protobuf-0.4.1

- old
+ new

@@ -9,22 +9,22 @@ Google::Protobuf::EnumDescriptorProto end def build(proto, opt) mod = opt[:module] - cls = mod.const_set proto.name, Class.new(Protobuf::Enum) + cls = mod.const_set(proto.name, Class.new(Protobuf::Enum)) proto.value.each do |value_proto| - cls.const_set value_proto.name, value_proto.number + cls.class_eval { define value_proto.name, value_proto.number } end end def unbuild(parent_proto) enum_proto = Google::Protobuf::EnumDescriptorProto.new enum_proto.name = @enum_class.name.split('::').last - @enum_class.constants.each do |const| + @enum_class.values.each do |name, value| enum_value_proto = Google::Protobuf::EnumValueDescriptorProto.new - enum_value_proto.name = const.to_s - enum_value_proto.number = @enum_class.const_get const + enum_value_proto.name = name.to_s + enum_value_proto.number = value.value enum_proto.value << enum_value_proto end parent_proto.enum_type << enum_proto end end