Class: GRPC::Core::CompositeCallCredentials

Inherits:
CallCredentials show all
Defined in:
src/ruby/lib/grpc/core/call_credentials.rb

Instance Attribute Summary

Attributes inherited from CallCredentials

#auth_proc

Instance Method Summary collapse

Constructor Details

#initialize(*creds) ⇒ CompositeCallCredentials

Returns a new instance of CompositeCallCredentials.



53
54
55
56
57
58
59
# File 'src/ruby/lib/grpc/core/call_credentials.rb', line 53

def initialize(*creds)
  flat_creds = creds.flatten.flat_map do |c|
    c.composite? ? c.creds : c
  end
  @creds = flat_creds.uniq
  super(proc { |context| (context) })
end

Instance Method Details

#compose(*others) ⇒ Object



75
76
77
78
79
# File 'src/ruby/lib/grpc/core/call_credentials.rb', line 75

def compose(*others)
  return self if others.empty?
  valid_others = validate_credentials_list!(others)
  CompositeCallCredentials.new(@creds + valid_others)
end

#composite?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'src/ruby/lib/grpc/core/call_credentials.rb', line 61

def composite?
  true
end

#get_metadata(context) ⇒ Object



65
66
67
68
69
70
71
72
73
# File 'src/ruby/lib/grpc/core/call_credentials.rb', line 65

def (context)
  @creds.each_with_object({}) do |c, |
     = c.(context)
    next unless 
    .merge!(
      .is_a?(Hash) ?  : fail(TypeError, "Call credentials must return Hash or nil, got #{.class}")
    )
  end
end