Module: GrpcRequiredAnnotator::ClassMethods

Defined in:
lib/grpc_required_annotator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#_required_hashObject (readonly)

Returns the value of attribute _required_hash.



10
11
12
# File 'lib/grpc_required_annotator.rb', line 10

def _required_hash
  @_required_hash
end

Instance Method Details

#method_added(name) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/grpc_required_annotator.rb', line 24

def method_added(name)
  @_required_hash ||= {}

  if @_last_required
    @_required_hash[name] = @_last_required
    @_last_required = nil
    define_required_validate(name)
  end

  super
end

#required(*fields) ⇒ Object

Raises:

  • (TypeError)


12
13
14
15
16
# File 'lib/grpc_required_annotator.rb', line 12

def required(*fields)
  raise TypeError.new("cannot annotate `required` without GRPC::GenericService module") unless self < GRPC::GenericService

  @_last_required = Required.new(fields)
end

#required_fields(method_name) ⇒ Object



18
19
20
21
22
# File 'lib/grpc_required_annotator.rb', line 18

def required_fields(method_name)
  return nil unless @_required_hash[method_name]

  @_required_hash[method_name].fields
end