Class: Farcall::Provider
- Inherits:
-
Object
- Object
- Farcall::Provider
- Defined in:
- lib/farcall/endpoint.rb
Overview
Could be used as a base class to export its methods to the remote. You are not limited to subclassing, instead, you can set any class instance as a provider setting it to the Farcall::Endpoint#provider. The provider has only one method^ which can not be accessed remotely: #far_interface, which is used locally to object interface to call remote methods for two-way connections.
Direct Known Subclasses
Instance Method Summary collapse
-
#close_connection ⇒ Object
close connection if need.
-
#far_interface ⇒ Farcall::Interface
Get remote interface like to call other party’s methiod, it can do it cimply by:.
-
#initialize(endpoint: nil, transport: nil, **params) ⇒ Provider
constructor
Create an instance connected to the Farcall::Transport or Farcall::Endpoint - use what suites you better.
Constructor Details
#initialize(endpoint: nil, transport: nil, **params) ⇒ Provider
Create an instance connected to the Farcall::Transport or Farcall::Endpoint - use what suites you better.
Please remember that Farcall::Transport instance could be used with only one connected object, unlike Farcall::Endpoint, which could be connected to several consumers.
265 266 267 268 269 270 271 272 273 274 275 |
# File 'lib/farcall/endpoint.rb', line 265 def initialize endpoint: nil, transport: nil, **params if endpoint || transport || params.size > 0 @endpoint = if endpoint endpoint else transport ||= Farcall::Transport.create **params Farcall::Endpoint.new transport end @endpoint.provider = self end end |
Instance Method Details
#close_connection ⇒ Object
close connection if need
288 289 290 |
# File 'lib/farcall/endpoint.rb', line 288 def close_connection @endpoint.close end |
#far_interface ⇒ Farcall::Interface
Get remote interface like to call other party’s methiod, it can do it cimply by:
far_interface.some_method('hello')
283 284 285 |
# File 'lib/farcall/endpoint.rb', line 283 def far_interface @endpoint.remote end |