Class: Rubyists::Dapr::Client::DummyClient
- Inherits:
-
Object
- Object
- Rubyists::Dapr::Client::DummyClient
- Includes:
- SemanticLogger::Loggable
- Defined in:
- lib/dapr/client.rb
Overview
Make a dummy client that responds to every method with a warning and the called method signature
Instance Method Summary collapse
-
#initialize(*_) ⇒ DummyClient
constructor
A new instance of DummyClient.
- #method_missing(method_name) ⇒ Object
- #respond_to_missing?(_method_name, _include_private = false) ⇒ Boolean
Constructor Details
#initialize(*_) ⇒ DummyClient
Returns a new instance of DummyClient.
42 43 44 |
# File 'lib/dapr/client.rb', line 42 def initialize(*_) logger.warn 'Dapr is not available (no DAPR_GRPC_PORT), using dummy client' end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/dapr/client.rb', line 46 def method_missing(method_name, *, &) self.class.define_method(method_name) do |*args, &block| logger.warn 'Dapr is not available (no DAPR_GRPC_PORT), using dummy client' { method_name:, args:, block: } end send(method_name, *, &) end |
Instance Method Details
#respond_to_missing?(_method_name, _include_private = false) ⇒ Boolean
54 55 56 |
# File 'lib/dapr/client.rb', line 54 def respond_to_missing?(_method_name, _include_private = false) true end |