Class: ForeignActor::ClientProxy

Inherits:
Celluloid::ActorProxy
  • Object
show all
Defined in:
lib/foreign_actor/client.rb

Defined Under Namespace

Classes: MethodMissingRedirector

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/foreign_actor/client.rb', line 40

def method_missing(meth, *args, &block)
  if (meth == :__send__) && (args[0] == :initialize)
    super
  else
    # bang methods are async calls
    type = :sync
    if meth.match(/!$/)
      meth = meth.to_s
      meth.slice!(-1, 1)
      type = :async
    end
    
    do_call(type, meth, args)
  end
end

Instance Method Details

#async(meth = nil, *args) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'lib/foreign_actor/client.rb', line 30

def async(meth = nil, *args)
  if meth
    do_call(:async, meth, args)
  else
    MethodMissingRedirector.new do |method, *args|
      do_call(:async, method, args)
    end
  end
end

#future(meth = nil, *args) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/foreign_actor/client.rb', line 20

def future(meth = nil, *args)
  if meth
    do_call(:future, meth, args)
  else
    MethodMissingRedirector.new do |method, *args|
      do_call(:future, method, args)
    end
  end
end