Sha256: 8101e3f01a5e2e5278d03dcd07e94475c1d624178c69ebd72c34fe73b980e5a4

Contents?: true

Size: 1013 Bytes

Versions: 40

Compression:

Stored size: 1013 Bytes

Contents

require_relative 'abstract_command_handler'

class InvokeInstanceMethodHandler < AbstractCommandHandler
  def initialize
    @required_parameters_count = 2
  end

  def process(command)
    return invoke_instance_method(command)
  end

  def invoke_instance_method(command)
    begin
      if command.payload.length < @required_parameters_count
        raise ArgumentError.new "InvokeInstanceMethod parameters mismatch"
      end
      if command.payload.length > 2
        arguments = command.payload[2..]
        return command.payload[0].send(command.payload[1], *arguments)
      else
        return command.payload[0].send(command.payload[1])
      end
    rescue NoMethodError
      methods = command.payload[0].methods
      message = "Method #{command.payload[1]} not found in object of class #{command.payload[0].class.name}. Available methods:\n"
      methods.each { |method_iter| message += "#{method_iter}\n" }
      raise Exception, message
    rescue Exception => e
      return e
    end
  end
end

Version data entries

40 entries across 20 versions & 1 rubygems

Version Path
javonet-ruby-sdk-2.5.7 lib/javonet-ruby-sdk/Binaries/Ruby/MacOs/X64/core/handler/invoke_instance_method_handler.rb
javonet-ruby-sdk-2.5.7 lib/javonet-ruby-sdk/Binaries/Ruby/Linux/X64/core/handler/invoke_instance_method_handler.rb
javonet-ruby-sdk-2.5.6 lib/javonet-ruby-sdk/Binaries/Ruby/MacOs/X64/core/handler/invoke_instance_method_handler.rb
javonet-ruby-sdk-2.5.6 lib/javonet-ruby-sdk/Binaries/Ruby/Linux/X64/core/handler/invoke_instance_method_handler.rb
javonet-ruby-sdk-2.5.5 lib/javonet-ruby-sdk/Binaries/Ruby/Linux/X64/core/handler/invoke_instance_method_handler.rb
javonet-ruby-sdk-2.5.5 lib/javonet-ruby-sdk/Binaries/Ruby/MacOs/X64/core/handler/invoke_instance_method_handler.rb
javonet-ruby-sdk-2.5.4 lib/javonet-ruby-sdk/Binaries/Ruby/MacOs/X64/core/handler/invoke_instance_method_handler.rb
javonet-ruby-sdk-2.5.4 lib/javonet-ruby-sdk/Binaries/Ruby/Linux/X64/core/handler/invoke_instance_method_handler.rb
javonet-ruby-sdk-2.5.3 lib/javonet-ruby-sdk/Binaries/Ruby/MacOs/X64/core/handler/invoke_instance_method_handler.rb
javonet-ruby-sdk-2.5.3 lib/javonet-ruby-sdk/Binaries/Ruby/Linux/X64/core/handler/invoke_instance_method_handler.rb
javonet-ruby-sdk-2.5.2 lib/javonet-ruby-sdk/Binaries/Ruby/MacOs/X64/core/handler/invoke_instance_method_handler.rb
javonet-ruby-sdk-2.5.2 lib/javonet-ruby-sdk/Binaries/Ruby/Linux/X64/core/handler/invoke_instance_method_handler.rb
javonet-ruby-sdk-2.5.1 lib/javonet-ruby-sdk/Binaries/Ruby/MacOs/X64/core/handler/invoke_instance_method_handler.rb
javonet-ruby-sdk-2.5.1 lib/javonet-ruby-sdk/Binaries/Ruby/Linux/X64/core/handler/invoke_instance_method_handler.rb
javonet-ruby-sdk-2.5.0 lib/javonet-ruby-sdk/Binaries/Ruby/MacOs/X64/core/handler/invoke_instance_method_handler.rb
javonet-ruby-sdk-2.5.0 lib/javonet-ruby-sdk/Binaries/Ruby/Linux/X64/core/handler/invoke_instance_method_handler.rb
javonet-ruby-sdk-2.4.11 lib/javonet-ruby-sdk/Binaries/Ruby/MacOs/X64/core/handler/invoke_instance_method_handler.rb
javonet-ruby-sdk-2.4.11 lib/javonet-ruby-sdk/Binaries/Ruby/Linux/X64/core/handler/invoke_instance_method_handler.rb
javonet-ruby-sdk-2.4.10 lib/javonet-ruby-sdk/Binaries/Ruby/Linux/X64/core/handler/invoke_instance_method_handler.rb
javonet-ruby-sdk-2.4.10 lib/javonet-ruby-sdk/Binaries/Ruby/MacOs/X64/core/handler/invoke_instance_method_handler.rb