Module: Protobuf::Field

Defined in:
lib/protobuf/message/field.rb

Defined Under Namespace

Classes: BaseField, BoolField, BytesField, DoubleField, EnumField, FieldArray, FieldProxy, Fixed32Field, Fixed64Field, FloatField, Int32Field, Int64Field, IntegerField, MessageField, Sfixed32Field, Sfixed64Field, SignedIntegerField, Sint32Field, Sint64Field, StringField, Uint32Field, Uint64Field, VarintField

Constant Summary

PREDEFINED_TYPES =
[
  :double,   :float,
  :int32,    :int64,
  :uint32,   :uint64,
  :sint32,   :sint64,
  :fixed32,  :fixed64,
  :sfixed32, :sfixed64,
  :string,   :bytes,
  :bool,
].freeze

Class Method Summary (collapse)

Class Method Details

+ (Object) build(message_class, rule, type, name, tag, options = {})



19
20
21
22
23
24
25
26
27
# File 'lib/protobuf/message/field.rb', line 19

def self.build(message_class, rule, type, name, tag, options={})
  field_class = \
    if PREDEFINED_TYPES.include?(type)
      const_get("#{type.to_s.capitalize}Field")
    else
      FieldProxy
    end
  field_class.new(message_class, rule, type, name, tag, options)
end