Class: ResolveInstanceHandler

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

Instance Method Summary collapse

Methods inherited from AbstractHandler

#handle_command, #validate

Constructor Details

#initializeResolveInstanceHandler

Returns a new instance of ResolveInstanceHandler.



9
10
11
# File 'lib/hypertube-ruby-sdk/core/handler/resolve_instance_handler.rb', line 9

def initialize
  @required_parameters_count = 1
end

Instance Method Details

#process(command) ⇒ Object



13
14
15
# File 'lib/hypertube-ruby-sdk/core/handler/resolve_instance_handler.rb', line 13

def process(command)
  resolve_reference(command)
end

#resolve_reference(command) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/hypertube-ruby-sdk/core/handler/resolve_instance_handler.rb', line 17

def resolve_reference(command)
  validate(command, @required_parameters_count, self.class.name)

  if command.runtime_name == RuntimeNameHt::RUBY
    return ReferencesCache.instance.resolve_reference(command.payload[0])
  end

  Command.new(command.runtime_name, CommandType::REFERENCE, command.payload[0])
end