Class: Farcall::Interface
- Inherits:
-
Object
- Object
- Farcall::Interface
- Defined in:
- lib/farcall/endpoint.rb
Overview
Interface to the remote provider via Farcall protocols. Works the same as the normal, local object, but slower. This interface is returned by Endpoint#remote. The Interface transparently creates methods as you call them to speed up subsequent calls.
There is no way to check that the remote responds to some method other than call it and catch the exception.
See RemoteError for more information on passing errors.
Instance Attribute Summary collapse
-
#endpoint ⇒ Object
readonly
the Endpoint to which this interface is connected.
Instance Method Summary collapse
-
#initialize(endpoint: nil, transport: nil, provider: nil, **params) ⇒ Interface
constructor
Create interface connected to some endpoint ar transpost.
-
#method_missing(method_name, *arguments, **kw_arguments, &block) ⇒ Object
used internally to synthesize the proxy method.
-
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
used internally to synthesize the proxy method.
Constructor Details
#initialize(endpoint: nil, transport: nil, provider: nil, **params) ⇒ Interface
Create interface connected to some endpoint ar transpost.
Please remember that Farcall::Transport instance could be used with only one connected object, unlike the Farcall::Endpoint, which could be connected to several consumers.
332 333 334 335 336 337 338 339 |
# File 'lib/farcall/endpoint.rb', line 332 def initialize endpoint: nil, transport: nil, provider: nil, **params @endpoint = if endpoint endpoint else Farcall::Endpoint.new(transport || Farcall::Transport.create(**params)) end provider and @endpoint.provider = provider end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *arguments, **kw_arguments, &block) ⇒ Object
used internally to synthesize the proxy method.
345 346 347 348 349 350 351 352 |
# File 'lib/farcall/endpoint.rb', line 345 def method_missing(method_name, *arguments, **kw_arguments, &block) instance_eval <<-End def #{method_name} *arguments, **kw_arguments @endpoint.sync_call '#{method_name}', *arguments, **kw_arguments end End @endpoint.sync_call method_name, *arguments, **kw_arguments end |
Instance Attribute Details
#endpoint ⇒ Object (readonly)
the Endpoint to which this interface is connected.
342 343 344 |
# File 'lib/farcall/endpoint.rb', line 342 def endpoint @endpoint end |
Instance Method Details
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
used internally to synthesize the proxy method.
355 356 357 |
# File 'lib/farcall/endpoint.rb', line 355 def respond_to_missing?(method_name, include_private = false) true end |