Class: Protobuf::Field::FieldProxy
- Inherits:
-
Object
- Object
- Protobuf::Field::FieldProxy
- Defined in:
- lib/protobuf/message/field.rb
Instance Method Summary collapse
-
#initialize(message_class, rule, type, name, tag, opts = {}) ⇒ FieldProxy
constructor
A new instance of FieldProxy.
- #ready? ⇒ Boolean
- #setup ⇒ Object
- #typename_to_class(message_class, type) ⇒ Object
Constructor Details
#initialize(message_class, rule, type, name, tag, opts = {}) ⇒ FieldProxy
Returns a new instance of FieldProxy.
174 175 176 177 |
# File 'lib/protobuf/message/field.rb', line 174 def initialize(, rule, type, name, tag, opts={}) , @rule, @type, @name, @tag, @opts = , rule, type, name, tag, opts end |
Instance Method Details
#ready? ⇒ Boolean
179 |
# File 'lib/protobuf/message/field.rb', line 179 def ready?; false end |
#setup ⇒ Object
181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/protobuf/message/field.rb', line 181 def setup type = typename_to_class , @type field_class = if type.superclass == Protobuf::Enum Protobuf::Field::EnumField elsif type.superclass == Protobuf::Message Protobuf::Field::MessageField else raise $! end field_class.new , @rule, type, @name, @tag, @opts end |
#typename_to_class(message_class, type) ⇒ Object
194 195 196 197 198 199 200 201 202 203 204 205 |
# File 'lib/protobuf/message/field.rb', line 194 def typename_to_class(, type) modules = .to_s.split('::') while begin type = eval((modules | [type.to_s]).join('::')) break rescue NameError modules.empty? ? raise($!) : modules.pop end end type end |