Module: RubySkynet::Base::InstanceMethods

Defined in:
lib/ruby_skynet/base.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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

Implement methods that call the remote Service



16
17
18
19
20
21
22
23
24
# File 'lib/ruby_skynet/base.rb', line 16

def method_missing(method, *args, &block)
  result = ruby_skynet_client.call(method, *args)
  # Define the method if the call was successful and no-one else already
  # created the method
  if result[:exception].nil? && !self.class.method_defined?(method)
    self.class.send(:define_method, method) {|*args| ruby_skynet_client.call(method, *args)}
  end
  result
end

Instance Method Details

#ruby_skynet_clientObject



26
27
28
# File 'lib/ruby_skynet/base.rb', line 26

def ruby_skynet_client
  @ruby_skynet_client ||= RubySkynet::Client.new(self.class.skynet_name, self.class.skynet_version || '*', self.class.skynet_region)
end