Module: Ruby::RPC::DeferCalls

Included in:
Remote
Defined in:
lib/ruby/rpc/defer_calls.rb

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



16
17
18
19
20
# File 'lib/ruby/rpc/defer_calls.rb', line 16

def method_missing method, *args, &block
  super unless Ruby::RPC::CLIENT
  @client ||= RedisRPC::Client.new Redis.new(url:Ruby::RPC::URL,driver: :hiredis), (@channel || self.to_s), timeout: Ruby::RPC::TIMEOUT
  @client.send method, *args, &block
end

Class Method Details

.method_missing(method, *args, &block) ⇒ Object



5
6
7
8
9
10
# File 'lib/ruby/rpc/defer_calls.rb', line 5

def method_missing method, *args, &block
  puts "Class Method #{name} missing"
  super unless Ruby::RPC::CLIENT
  @client ||= RedisRPC::Client.new Redis.new(url:Ruby::RPC::URL,driver: :hiredis), self.to_s, timeout: Ruby::RPC::TIMEOUT
  @client.send method, *args, &block
end

Instance Method Details

#initialize(*args, &block) ⇒ Object



12
13
14
15
# File 'lib/ruby/rpc/defer_calls.rb', line 12

def initialize *args, &block
  @channel = Ruby::RPC::Remote.build_remote self.class
  super *args, &block
end