Class: Protod

Inherits:
Object
  • Object
show all
Defined in:
lib/protod.rb,
lib/protod/version.rb,
lib/protod/rake_task.rb,
lib/protod/proto/part.rb,
lib/protod/ruby_ident.rb,
lib/protod/interpreter.rb,
lib/protod/proto/field.rb,
lib/protod/proto/oneof.rb,
lib/protod/rpc/handler.rb,
lib/protod/rpc/request.rb,
lib/protod/rpc/response.rb,
lib/protod/configuration.rb,
lib/protod/proto/builder.rb,
lib/protod/proto/message.rb,
lib/protod/proto/package.rb,
lib/protod/proto/service.rb,
lib/protod/proto/features.rb,
lib/protod/interpreter/rpc.rb,
lib/protod/proto/procedure.rb,
lib/protod/protocol_buffers.rb,
lib/protod/interpreter/builtin.rb,
lib/generators/protod/gruf_generator.rb,
lib/generators/protod/task_generator.rb,
lib/protod/interpreter/active_record.rb

Defined Under Namespace

Modules: Proto, ProtocolBuffers, Rpc, Types Classes: Configuration, GrufGenerator, Interpreter, RakeTask, RubyIdent, TaskGenerator

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.clear!Object



49
50
51
52
53
54
55
56
# File 'lib/protod.rb', line 49

def clear!
  @configures = nil
  @configuration = nil
  Protod::Proto::Package.clear!
  Protod::Rpc::Request.clear!
  Protod::Rpc::Response.clear!
  Protod::Interpreter.clear!
end

.configurationObject



38
39
40
41
42
43
44
45
46
47
# File 'lib/protod.rb', line 38

def configuration
  @configuration ||= Protod::Configuration.new.tap do |c|
    # Interpreters will be needed by Protod::Configuration#register_interpreter_for
    Protod::Interpreter::Builtin.setup!
    Protod::Interpreter::ActiveRecord.setup!
    Protod::Interpreter::Rpc.setup!

    @configures&.each { _1.call(c) }
  end
end

.configure(&body) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/protod.rb', line 29

def configure(&body)
  if @configuration
    body.call(@configuration)
  else
    @configures ||= []
    @configures.push(body)
  end
end

.setup!Object



58
59
60
61
62
# File 'lib/protod.rb', line 58

def setup!
  Protod.configuration.builders.each(&:build)
  Protod::Proto::Package.roots.each(&:freeze)
  Protod::Interpreter.setup_reverse_lookup!
end