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 to the endpoint.

Parameters:



231
232
233
# File 'lib/farcall/em_farcall.rb', line 231

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



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

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)


244
245
246
# File 'lib/farcall/em_farcall.rb', line 244

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