Class: ResolveInstanceHandler

Inherits:
AbstractCommandHandler show all
Defined in:
lib/javonet-ruby-sdk/core/handler/resolve_instance_handler.rb

Instance Method Summary collapse

Methods inherited from AbstractCommandHandler

#handle_command, #iterate

Constructor Details

#initializeResolveInstanceHandler

Returns a new instance of ResolveInstanceHandler.



7
8
9
# File 'lib/javonet-ruby-sdk/core/handler/resolve_instance_handler.rb', line 7

def initialize
  @required_parameters_count = 1
end

Instance Method Details

#process(command) ⇒ Object



11
12
13
# File 'lib/javonet-ruby-sdk/core/handler/resolve_instance_handler.rb', line 11

def process(command)
  resolve_reference(command)
end

#resolve_reference(command) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/javonet-ruby-sdk/core/handler/resolve_instance_handler.rb', line 15

def resolve_reference(command)
  if command.payload.length != @required_parameters_count
    raise ArgumentError.new "Resolve Instance parameters mismatch"
  end
  begin
    if command.runtime_name == RuntimeNameJavonet::RUBY
      return ReferencesCache.instance.resolve_reference(command.payload[0])
    else
      return new Command(command.runtime_name, CommandType::REFERENCE, command.payload[0])
    end
  rescue Exception => ex
    return ex
  end
end