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, InvalidRuleError, MessageField, Sfixed32Field, Sfixed64Field, SignedIntegerField, Sint32Field, Sint64Field, StringField, Uint32Field, Uint64Field, VarintField

Class Method Summary collapse

Class Method Details

.build(message_class, rule, type, name, tag, opts = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/protobuf/message/field.rb', line 6

def self.build(message_class, rule, type, name, tag, opts={})
  field_class =
    if [:double, :float, :int32, :int64, :uint32, :uint64,
      :sint32, :sint64, :fixed32, :fixed64, :sfixed32, :sfixed64,
      :bool, :string, :bytes].include? type
      eval "Protobuf::Field::#{type.to_s.capitalize}Field"
    else
      Protobuf::Field::FieldProxy
    end
  field_class.new message_class, rule, type, name, tag, opts
end