Class: Farcall::Interface
- Inherits:
-
Object
- Object
- Farcall::Interface
- Defined in:
- lib/farcall/endpoint.rb
Overview
Intervace to the remote provider via Farcall protocols. Works the same as if the object would be in local data, but slower :) The same as calling Farcall::Endpoint#interface
RemoteInterface transparently creates methods as you call them to speedup subsequent calls.
There is no way to check that the remote responds to some method other than call it and catch the exception
Instance Attribute Summary collapse
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
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
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
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 Farcall::Endpoint, which could be connected to several consumers.
301 302 303 304 305 306 307 308 |
# File 'lib/farcall/endpoint.rb', line 301 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
312 313 314 315 316 317 318 319 |
# File 'lib/farcall/endpoint.rb', line 312 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)
Returns the value of attribute endpoint.
310 311 312 |
# File 'lib/farcall/endpoint.rb', line 310 def endpoint @endpoint end |
Instance Method Details
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
321 322 323 |
# File 'lib/farcall/endpoint.rb', line 321 def respond_to_missing?(method_name, include_private = false) true end |