Class: ProtoPlugin::Context
- Inherits:
-
Object
- Object
- ProtoPlugin::Context
- Defined in:
- lib/proto_plugin/context.rb
Overview
An object that is responsible for organizing the graph of imported descriptors for a given invocation of a plugin.
It provides many helpers for looking up a file, message, or other descriptor.
Instance Method Summary collapse
-
#file_by_filename(name) ⇒ ProtoPlugin::FileDescriptor?
Finds an imported file descriptor with the given
name
attribute. -
#initialize(request:) ⇒ Context
constructor
Initializes a context from a given
Google::Protobuf::Compiler::CodeGeneratorRequest
. - #type_by_proto_name(name) ⇒ Object
Constructor Details
#initialize(request:) ⇒ Context
Initializes a context from a given Google::Protobuf::Compiler::CodeGeneratorRequest
.
10 11 12 13 |
# File 'lib/proto_plugin/context.rb', line 10 def initialize(request:) index_files_by_filename(request.proto_file) index_types_by_proto_name end |
Instance Method Details
#file_by_filename(name) ⇒ ProtoPlugin::FileDescriptor?
Finds an imported file descriptor with the given name
attribute.
19 20 21 |
# File 'lib/proto_plugin/context.rb', line 19 def file_by_filename(name) @files_by_filename[name] end |
#type_by_proto_name(name) ⇒ Object
23 24 25 |
# File 'lib/proto_plugin/context.rb', line 23 def type_by_proto_name(name) @types_by_proto_name[name] end |