module Protobuf

Constants

Deprecation
FieldDeprecation

Public Class Methods

deprecator() click to toggle source
# File lib/protobuf/deprecation.rb, line 81
def self.deprecator
  @deprecator ||= Deprecation.new('4.0', to_s).tap do |deprecation|
    deprecation.silenced = ENV.key?('PB_IGNORE_DEPRECATIONS')
    deprecation.behavior = :stderr
  end
end
field_deprecator() click to toggle source
# File lib/protobuf/deprecation.rb, line 88
def self.field_deprecator
  @field_deprecator ||= FieldDeprecation.new.tap do |deprecation|
    deprecation.silenced = ENV.key?('PB_IGNORE_DEPRECATIONS')
    deprecation.behavior = :stderr
  end
end
ignore_unknown_fields=(value) click to toggle source
# File lib/protobuf.rb, line 24
def self.ignore_unknown_fields=(value)
  @ignore_unknown_fields = !!value
end
ignore_unknown_fields?() click to toggle source

Permit unknown field on Message initialization

Default: true

Simple boolean to define whether we want to permit unknown fields on Message intialization; otherwise a ::Protobuf::FieldNotDefinedError is thrown.

# File lib/protobuf.rb, line 20
def self.ignore_unknown_fields?
  !defined?(@ignore_unknown_fields) || @ignore_unknown_fields
end
print_deprecation_warnings=(value) click to toggle source
print_deprecation_warnings?() click to toggle source

Print Deprecation Warnings

Default: true

Simple boolean to define whether we want field deprecation warnings to be printed to stderr or not. The rpc_server has an option to set this value explicitly, or you can turn this option off by setting ENV to a non-empty value.

The rpc_server option will override the ENV setting.

Public Instance Methods

define_deprecated_methods(target_module, method_hash) click to toggle source
# File lib/protobuf/deprecation.rb, line 57
def define_deprecated_methods(target_module, method_hash)
  target_module.module_eval do
    method_hash.each do |old_method, new_method|
      alias_method old_method, new_method
    end
  end

  deprecate_methods(target_module, method_hash)
end
deprecate_method(target_module, method_name) click to toggle source
# File lib/protobuf/deprecation.rb, line 69
def deprecate_method(target_module, method_name)
  deprecate_methods(target_module, method_name => target_module)
end
deprecated_method_warning(method_name, target_module) click to toggle source
# File lib/protobuf/deprecation.rb, line 75
def deprecated_method_warning(method_name, target_module)
  "#{target_module.name}##{method_name} field usage is deprecated"
end
new(deprecation_horizon = nil, *) click to toggle source
# File lib/protobuf/deprecation.rb, line 48
def new(deprecation_horizon = nil, *)
  self.deprecation_horizon = deprecation_horizon if deprecation_horizon
  self
end