Class: EmFarcall::Interface

Inherits:
Object
  • Object
show all
Defined in:
lib/farcall/em_farcall.rb

Overview

Interface to the remote provider via Farcall protocols. Works the same as if the object is local and yields block in return, unlike Farcall::Interface that blocks

RemoteInterface transparently creates methods as you call them to speedup subsequent calls.

Instance Method Summary collapse

Constructor Details

#initialize(endpoint) ⇒ 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.

Parameters:



233
234
235
# File 'lib/farcall/em_farcall.rb', line 233

def initialize(endpoint)
  @endpoint = endpoint
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *arguments, **kw_arguments, &block) ⇒ Object



237
238
239
240
241
242
243
244
# File 'lib/farcall/em_farcall.rb', line 237

def method_missing(method_name, *arguments, **kw_arguments, &block)
  instance_eval <<-End
    def #{method_name} *arguments, **kw_arguments, &block
      @endpoint.call '#{method_name}', *arguments, **kw_arguments, &block
    end
  End
  @endpoint.call method_name, *arguments, **kw_arguments, &block
end

Instance Method Details

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


246
247
248
# File 'lib/farcall/em_farcall.rb', line 246

def respond_to_missing?(method_name, include_private = false)
  true
end