Class: Protobuf::Generators::ExtensionGenerator

Inherits:
Base
  • Object
show all
Defined in:
lib/protobuf/generators/extension_generator.rb

Constant Summary

Constants included from Printable

Printable::PARENT_CLASS_ENUM, Printable::PARENT_CLASS_MESSAGE, Printable::PARENT_CLASS_SERVICE

Instance Attribute Summary

Attributes inherited from Base

#descriptor, #namespace, #options

Instance Method Summary collapse

Methods inherited from Base

#fully_qualified_type_namespace, #run_once, #serialize_value, #to_s, #type_namespace, validate_tags

Methods included from Printable

#init_printer

Constructor Details

#initialize(message_type, field_descriptors, indent_level) ⇒ ExtensionGenerator

Returns a new instance of ExtensionGenerator.



8
9
10
11
12
# File 'lib/protobuf/generators/extension_generator.rb', line 8

def initialize(message_type, field_descriptors, indent_level)
  super(nil, indent_level)
  @message_type = modulize(message_type)
  @field_descriptors = field_descriptors
end

Instance Method Details

#compileObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/protobuf/generators/extension_generator.rb', line 14

def compile
  run_once(:compile) do
    print_class(@message_type, :message) do
      group = GroupGenerator.new(current_indent)
      group.add_extension_fields(@field_descriptors)
      group.order = [:extension_field]
      print group.to_s
    end
  end
end