Class: Hypertube::Sdk::InvocationContext
- Inherits:
-
Hypertube::Sdk::Internal::AbstractInvocationContext
- Object
- Hypertube::Sdk::Internal::AbstractInvocationContext
- Hypertube::Sdk::InvocationContext
- Includes:
- Enumerable
- Defined in:
- lib/hypertube-ruby-sdk/sdk/invocation_context.rb
Class Attribute Summary collapse
-
.instances_to_be_materialized ⇒ Object
readonly
Returns the value of attribute instances_to_be_materialized.
-
.instances_to_be_materialized_mutex ⇒ Object
readonly
Returns the value of attribute instances_to_be_materialized_mutex.
Instance Attribute Summary collapse
-
#connection_data ⇒ Object
Returns the value of attribute connection_data.
-
#current_command ⇒ Object
readonly
Returns the value of attribute current_command.
-
#guid ⇒ Object
readonly
Returns the value of attribute guid.
-
#response_command ⇒ Object
readonly
Returns the value of attribute response_command.
Instance Method Summary collapse
- #[](*indexes) ⇒ Object
- #[]=(*indexes_and_value) ⇒ Object
- #build_command(command) ⇒ Object
- #build_invocation_context(local_command) ⇒ Object
-
#create_instance(*args) ⇒ Hypertube::Sdk::InvocationContext
Creates a new instance of a class in the target runtime.
-
#create_null ⇒ Hypertube::Sdk::InvocationContext
Creates a null object of a specific type in the target runtime.
- #encapsulate_payload_item(payload_item) ⇒ Object
-
#execute(connection_data = nil) ⇒ Hypertube::Sdk::InvocationContext
Executes the current command.
- #execute_async ⇒ Object
-
#get_enum_name ⇒ Hypertube::Sdk::InvocationContext
Retrieves the name of an enum from the target runtime.
-
#get_enum_value ⇒ Hypertube::Sdk::InvocationContext
Retrieves the value of an enum from the target runtime.
-
#get_index(*indexes) ⇒ Hypertube::Sdk::InvocationContext
Retrieves the value at a specific indexes in an array from the target runtime.
-
#get_instance_field(field_name) ⇒ Hypertube::Sdk::InvocationContext
Retrieves the value of an instance field from the target runtime.
-
#get_instance_method_as_delegate(method_name, *args) ⇒ Hypertube::Sdk::InvocationContext
Retrieves an instance method as a delegate from the target runtime.
-
#get_rank ⇒ Hypertube::Sdk::InvocationContext
Retrieves the rank of an array from the target runtime.
-
#get_ref_value ⇒ Hypertube::Sdk::InvocationContext
Retrieves the value of a reference from the target runtime.
-
#get_size ⇒ Hypertube::Sdk::InvocationContext
Retrieves the number of elements from the target runtime.
-
#get_static_field(field_name) ⇒ Hypertube::Sdk::InvocationContext
Retrieves the value of a static field from the target runtime.
-
#get_static_method_as_delegate(method_name, *args) ⇒ Hypertube::Sdk::InvocationContext
Retrieves a static method as a delegate from the target runtime.
-
#get_value ⇒ Object
Retrieves the value of the current command from the target runtime.
-
#initialize(runtime_name, connection_type, connection_data, command, is_executed = false, is_stateless = false) ⇒ InvocationContext
constructor
A new instance of InvocationContext.
-
#invoke_generic_method(method_name, *args) ⇒ Hypertube::Sdk::InvocationContext
Invokes a generic method on the target runtime.
-
#invoke_generic_static_method(method_name, *args) ⇒ Hypertube::Sdk::InvocationContext
Invokes a generic static method on the target runtime.
-
#invoke_instance_method(method_name, *args) ⇒ Hypertube::Sdk::InvocationContext
Invokes an instance method on the target runtime.
-
#invoke_static_method(method_name, *args) ⇒ Hypertube::Sdk::InvocationContext
Invokes a static method on the target runtime.
-
#iterator ⇒ Object
def finalize(command, is_executed, interpreter, connection_type, connection_data) proc do if command.command_type == Hypertube::Utils::CommandType::REFERENCE && is_executed == true destruct_command = Hypertube::Utils::Command.new(@runtime_name, Hypertube::Utils::CommandType::DESTRUCT_REFERENCE, command.payload) interpreter.execute(destruct_command, connection_type, connection_data) end end end.
-
#process_update_invocation_context_commands(response_command) ⇒ Hypertube::Utils::Command
Always strips ValueForUpdate commands from the response payload.
-
#register_for_update ⇒ Hypertube::Sdk::InvocationContext
Registers the current context for updates by wrapping it in a REGISTER_FOR_UPDATE command.
-
#retrieve_array ⇒ Object, Array
Retrieves an array from the target runtime.
-
#set_index(indexes, value) ⇒ Hypertube::Sdk::InvocationContext
Sets the value at a specific index in an array in the target runtime.
-
#set_instance_field(field_name, value) ⇒ Hypertube::Sdk::InvocationContext
Sets the value of an instance field in the target runtime.
-
#set_static_field(field_name, value) ⇒ Hypertube::Sdk::InvocationContext
Sets the value of a static field in the target runtime.
Methods inherited from Hypertube::Sdk::Internal::AbstractInvocationContext
Constructor Details
#initialize(runtime_name, connection_type, connection_data, command, is_executed = false, is_stateless = false) ⇒ InvocationContext
Returns a new instance of InvocationContext.
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/hypertube-ruby-sdk/sdk/invocation_context.rb', line 29 def initialize(runtime_name, connection_type, connection_data, command, is_executed = false, is_stateless = false) @is_executed = is_executed @is_stateless = is_stateless @runtime_name = runtime_name @connection_type = connection_type @connection_data = connection_data @current_command = command @response_command = nil @guid = SecureRandom.uuid @materialization_mutex = Mutex.new # generates error: ruby/lib/Hypertube::Sdk::RuntimeBridge.rb-ruby-sdk/sdk/internal/invocation_context.rb:17: warning: finalizer references object to be finalized # ObjectSpace.define_finalizer(self, self.finalize(@current_command, @is_executed, @interpreter, @connection_type, @connection_data)) end |
Class Attribute Details
.instances_to_be_materialized ⇒ Object (readonly)
Returns the value of attribute instances_to_be_materialized.
23 24 25 |
# File 'lib/hypertube-ruby-sdk/sdk/invocation_context.rb', line 23 def instances_to_be_materialized @instances_to_be_materialized end |
.instances_to_be_materialized_mutex ⇒ Object (readonly)
Returns the value of attribute instances_to_be_materialized_mutex.
23 24 25 |
# File 'lib/hypertube-ruby-sdk/sdk/invocation_context.rb', line 23 def instances_to_be_materialized_mutex @instances_to_be_materialized_mutex end |
Instance Attribute Details
#connection_data ⇒ Object
Returns the value of attribute connection_data.
27 28 29 |
# File 'lib/hypertube-ruby-sdk/sdk/invocation_context.rb', line 27 def connection_data @connection_data end |
#current_command ⇒ Object (readonly)
Returns the value of attribute current_command.
26 27 28 |
# File 'lib/hypertube-ruby-sdk/sdk/invocation_context.rb', line 26 def current_command @current_command end |
#guid ⇒ Object (readonly)
Returns the value of attribute guid.
26 27 28 |
# File 'lib/hypertube-ruby-sdk/sdk/invocation_context.rb', line 26 def guid @guid end |
#response_command ⇒ Object (readonly)
Returns the value of attribute response_command.
26 27 28 |
# File 'lib/hypertube-ruby-sdk/sdk/invocation_context.rb', line 26 def response_command @response_command end |
Instance Method Details
#[](*indexes) ⇒ Object
61 62 63 |
# File 'lib/hypertube-ruby-sdk/sdk/invocation_context.rb', line 61 def [](*indexes) get_index(*indexes).execute end |
#[]=(*indexes_and_value) ⇒ Object
65 66 67 68 |
# File 'lib/hypertube-ruby-sdk/sdk/invocation_context.rb', line 65 def []=(*indexes_and_value) value = indexes_and_value.pop set_index(indexes_and_value, value).execute end |
#build_command(command) ⇒ Object
451 452 453 454 455 456 457 458 |
# File 'lib/hypertube-ruby-sdk/sdk/invocation_context.rb', line 451 def build_command(command) return @current_command if command.nil? || command.payload.nil? command.payload.each_index do |i| command.payload[i] = encapsulate_payload_item(command.payload[i]) end command.prepend_arg_to_payload(@current_command) end |
#build_invocation_context(local_command) ⇒ Object
446 447 448 449 |
# File 'lib/hypertube-ruby-sdk/sdk/invocation_context.rb', line 446 def build_invocation_context(local_command) Hypertube::Sdk::InvocationContext.new(@runtime_name, @connection_type, @connection_data, build_command(local_command), @is_executed, @is_stateless) end |
#create_instance(*args) ⇒ Hypertube::Sdk::InvocationContext
Creates a new instance of a class in the target runtime. Invokes a constructor on the target runtime and registers the returned context for updates.
203 204 205 206 207 |
# File 'lib/hypertube-ruby-sdk/sdk/invocation_context.rb', line 203 def create_instance(*args) local_command = Hypertube::Utils::Command.new(@runtime_name, Hypertube::Utils::CommandType::CREATE_CLASS_INSTANCE, [*args]) create_instance_inv_ctx = build_invocation_context(local_command) create_instance_inv_ctx.register_for_update end |
#create_null ⇒ Hypertube::Sdk::InvocationContext
Creates a null object of a specific type in the target runtime.
355 356 357 358 |
# File 'lib/hypertube-ruby-sdk/sdk/invocation_context.rb', line 355 def create_null local_command = Hypertube::Utils::Command.new(@runtime_name, Hypertube::Utils::CommandType::CREATE_NULL, []) build_invocation_context(local_command) end |
#encapsulate_payload_item(payload_item) ⇒ Object
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 |
# File 'lib/hypertube-ruby-sdk/sdk/invocation_context.rb', line 460 def encapsulate_payload_item(payload_item) if payload_item.is_a? Hypertube::Utils::Command if payload_item.command_type == Hypertube::Utils::CommandType::VALUE || payload_item.command_type == Hypertube::Utils::CommandType::ARRAY return payload_item end payload_item.payload.each_index do |i| payload_item.payload[i] = encapsulate_payload_item(payload_item.payload[i]) end payload_item elsif payload_item.is_a? Hypertube::Sdk::InvocationContext payload_item.current_command elsif payload_item.is_a? Array copied_array = payload_item.map { |item| encapsulate_payload_item(item) } Hypertube::Utils::Command.new(@runtime_name, Hypertube::Utils::CommandType::ARRAY, copied_array) elsif Hypertube::Utils::TypesHandler.primitive_or_none?(payload_item) Hypertube::Utils::Command.new(@runtime_name, Hypertube::Utils::CommandType::VALUE, payload_item.nil? ? [nil] : [*payload_item]) else raise TypeError, "Unsupported payload item type: #{payload_item.class} for payload item: #{payload_item}." end end |
#execute(connection_data = nil) ⇒ Hypertube::Sdk::InvocationContext
Executes the current command. Because invocation context is building the intent of executing a particular expression on the target environment, we call the initial state of invocation context as non-materialized. The non-materialized context wraps either a single command or chain of recursively nested commands. Commands are becoming nested through each invocation of methods on Invocation Context. Each invocation triggers the creation of a new Invocation Context instance wrapping the current command with new parent command valid for invoked method. Developer can decide on any moment of the materialization for the context, taking full control of the chunks of the expression being transferred and processed on target runtime.
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/hypertube-ruby-sdk/sdk/invocation_context.rb', line 79 def execute(connection_data = nil) @connection_data = connection_data unless connection_data.nil? raise 'currentCommand is undefined in Hypertube::Sdk::InvocationContext execute method' if @current_command.nil? return self if @is_stateless && @current_command.command_type != Hypertube::Utils::CommandType::PASS_BY_VALUE @response_command = Hypertube::Core::Interpreter::Interpreter.execute(@current_command, @connection_data) if @response_command.command_type == Hypertube::Utils::CommandType::EXCEPTION exception = Hypertube::Utils::Exceptions::ExceptionThrower.throw_exception(@response_command) raise(exception) end if @current_command.command_type == Hypertube::Utils::CommandType::CREATE_CLASS_INSTANCE @current_command = @response_command @is_executed = true return self end @response_command = process_update_invocation_context_commands(@response_command) Hypertube::Sdk::InvocationContext.new(@runtime_name, @connection_type, @connection_data, @response_command, true, @is_stateless) end |
#execute_async ⇒ Object
104 105 106 107 108 |
# File 'lib/hypertube-ruby-sdk/sdk/invocation_context.rb', line 104 def execute_async Thread.new do execute end end |
#get_enum_name ⇒ Hypertube::Sdk::InvocationContext
Retrieves the name of an enum from the target runtime.
331 332 333 334 |
# File 'lib/hypertube-ruby-sdk/sdk/invocation_context.rb', line 331 def get_enum_name local_command = Hypertube::Utils::Command.new(@runtime_name, Hypertube::Utils::CommandType::GET_ENUM_NAME, []) build_invocation_context(local_command) end |
#get_enum_value ⇒ Hypertube::Sdk::InvocationContext
Retrieves the value of an enum from the target runtime.
339 340 341 342 |
# File 'lib/hypertube-ruby-sdk/sdk/invocation_context.rb', line 339 def get_enum_value local_command = Hypertube::Utils::Command.new(@runtime_name, Hypertube::Utils::CommandType::GET_ENUM_VALUE, []) build_invocation_context(local_command) end |
#get_index(*indexes) ⇒ Hypertube::Sdk::InvocationContext
Retrieves the value at a specific indexes in an array from the target runtime.
277 278 279 280 |
# File 'lib/hypertube-ruby-sdk/sdk/invocation_context.rb', line 277 def get_index(*indexes) local_command = Hypertube::Utils::Command.new(@runtime_name, Hypertube::Utils::CommandType::ARRAY_GET_ITEM, [*indexes]) build_invocation_context(local_command) end |
#get_instance_field(field_name) ⇒ Hypertube::Sdk::InvocationContext
Retrieves the value of an instance field from the target runtime.
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
# File 'lib/hypertube-ruby-sdk/sdk/invocation_context.rb', line 232 def get_instance_field(field_name) if @is_stateless value = Hypertube::Sdk::Tools::GetInstanceFieldHelper.get_field_value(@current_command, field_name) return_command = if Hypertube::Utils::TypesHandler.primitive_or_none?(value) Hypertube::Utils::Command.new(@runtime_name, Hypertube::Utils::CommandType::VALUE, value) elsif value.is_a?(Hypertube::Utils::Command) value else raise ArgumentError, "Unsupported type for stateless get_instance_field: #{value.class}" end return Hypertube::Sdk::InvocationContext.new( @runtime_name, @connection_type, @connection_data, return_command, false, @is_stateless ) end local_command = Hypertube::Utils::Command.new(@runtime_name, Hypertube::Utils::CommandType::GET_INSTANCE_FIELD, [field_name]) build_invocation_context(local_command) end |
#get_instance_method_as_delegate(method_name, *args) ⇒ Hypertube::Sdk::InvocationContext
Retrieves an instance method as a delegate from the target runtime.
@see Refer to this article on Hypertube Guides
375 376 377 378 |
# File 'lib/hypertube-ruby-sdk/sdk/invocation_context.rb', line 375 def get_instance_method_as_delegate(method_name, *args) local_command = Hypertube::Utils::Command.new(@runtime_name, Hypertube::Utils::CommandType::GET_INSTANCE_METHOD_AS_DELEGATE, [method_name, *args]) build_invocation_context(local_command) end |
#get_rank ⇒ Hypertube::Sdk::InvocationContext
Retrieves the rank of an array from the target runtime.
303 304 305 306 |
# File 'lib/hypertube-ruby-sdk/sdk/invocation_context.rb', line 303 def get_rank local_command = Hypertube::Utils::Command.new(@runtime_name, Hypertube::Utils::CommandType::ARRAY_GET_RANK, []) build_invocation_context(local_command) end |
#get_ref_value ⇒ Hypertube::Sdk::InvocationContext
Retrieves the value of a reference from the target runtime.
347 348 349 350 |
# File 'lib/hypertube-ruby-sdk/sdk/invocation_context.rb', line 347 def get_ref_value local_command = Hypertube::Utils::Command.new(@runtime_name, Hypertube::Utils::CommandType::GET_REF_VALUE, []) build_invocation_context(local_command) end |
#get_size ⇒ Hypertube::Sdk::InvocationContext
Retrieves the number of elements from the target runtime.
295 296 297 298 |
# File 'lib/hypertube-ruby-sdk/sdk/invocation_context.rb', line 295 def get_size local_command = Hypertube::Utils::Command.new(@runtime_name, Hypertube::Utils::CommandType::ARRAY_GET_SIZE, []) build_invocation_context(local_command) end |
#get_static_field(field_name) ⇒ Hypertube::Sdk::InvocationContext
Retrieves the value of a static field from the target runtime.
213 214 215 216 |
# File 'lib/hypertube-ruby-sdk/sdk/invocation_context.rb', line 213 def get_static_field(field_name) local_command = Hypertube::Utils::Command.new(@runtime_name, Hypertube::Utils::CommandType::GET_STATIC_FIELD, [field_name]) build_invocation_context(local_command) end |
#get_static_method_as_delegate(method_name, *args) ⇒ Hypertube::Sdk::InvocationContext
Retrieves a static method as a delegate from the target runtime.
365 366 367 368 |
# File 'lib/hypertube-ruby-sdk/sdk/invocation_context.rb', line 365 def get_static_method_as_delegate(method_name, *args) local_command = Hypertube::Utils::Command.new(@runtime_name, Hypertube::Utils::CommandType::GET_STATIC_METHOD_AS_DELEGATE, [method_name, *args]) build_invocation_context(local_command) end |
#get_value ⇒ Object
Retrieves the value of the current command from the target runtime.
423 424 425 426 427 |
# File 'lib/hypertube-ruby-sdk/sdk/invocation_context.rb', line 423 def get_value return @current_command.payload[0] if @current_command.command_type == Hypertube::Utils::CommandType::VALUE && Hypertube::Utils::TypesHandler.primitive_or_none?(@current_command.payload[0]) self end |
#invoke_generic_method(method_name, *args) ⇒ Hypertube::Sdk::InvocationContext
Invokes a generic method on the target runtime.
323 324 325 326 |
# File 'lib/hypertube-ruby-sdk/sdk/invocation_context.rb', line 323 def invoke_generic_method(method_name, *args) local_command = Hypertube::Utils::Command.new(@runtime_name, Hypertube::Utils::CommandType::INVOKE_GENERIC_METHOD, [method_name, *args]) build_invocation_context(local_command) end |
#invoke_generic_static_method(method_name, *args) ⇒ Hypertube::Sdk::InvocationContext
Invokes a generic static method on the target runtime.
313 314 315 316 |
# File 'lib/hypertube-ruby-sdk/sdk/invocation_context.rb', line 313 def invoke_generic_static_method(method_name, *args) local_command = Hypertube::Utils::Command.new(@runtime_name, Hypertube::Utils::CommandType::INVOKE_GENERIC_STATIC_METHOD, [method_name, *args]) build_invocation_context(local_command) end |
#invoke_instance_method(method_name, *args) ⇒ Hypertube::Sdk::InvocationContext
Invokes an instance method on the target runtime.
193 194 195 196 |
# File 'lib/hypertube-ruby-sdk/sdk/invocation_context.rb', line 193 def invoke_instance_method(method_name, *args) local_command = Hypertube::Utils::Command.new(@runtime_name, Hypertube::Utils::CommandType::INVOKE_INSTANCE_METHOD, [method_name, *args]) build_invocation_context(local_command) end |
#invoke_static_method(method_name, *args) ⇒ Hypertube::Sdk::InvocationContext
Invokes a static method on the target runtime.
169 170 171 172 173 174 175 176 |
# File 'lib/hypertube-ruby-sdk/sdk/invocation_context.rb', line 169 def invoke_static_method(method_name, *args) local_command = Hypertube::Utils::Command.new(@runtime_name, Hypertube::Utils::CommandType::INVOKE_STATIC_METHOD, [method_name, *args]) if @is_stateless local_inv_ctx = build_invocation_context(local_command) return local_inv_ctx.send(:pass_by_value) end build_invocation_context(local_command) end |
#iterator ⇒ Object
def finalize(command, is_executed, interpreter, connection_type, connection_data) proc do if command.command_type == Hypertube::Utils::CommandType::REFERENCE && is_executed == true destruct_command = Hypertube::Utils::Command.new(@runtime_name, Hypertube::Utils::CommandType::DESTRUCT_REFERENCE, command.payload) interpreter.execute(destruct_command, connection_type, connection_data) end end end
52 53 54 55 56 57 58 59 |
# File 'lib/hypertube-ruby-sdk/sdk/invocation_context.rb', line 52 def iterator if ![Hypertube::Utils::CommandType::REFERENCE, Hypertube::Utils::CommandType::ARRAY_GET_ITEM, Hypertube::Utils::CommandType::ARRAY_SET_ITEM].include? @current_command.command_type raise TypeError, "Object is not iterable for command type #{@current_command.command_type}" else Hypertube::Sdk::Internal::InvocationContextIterator.new(self) end end |
#process_update_invocation_context_commands(response_command) ⇒ Hypertube::Utils::Command
Always strips ValueForUpdate commands from the response payload. When stateful, also materializes registered InvocationContexts to Reference commands.
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/hypertube-ruby-sdk/sdk/invocation_context.rb', line 114 def process_update_invocation_context_commands(response_command) payload = response_command.payload return response_command if payload.nil? || payload.empty? commands_to_update = payload.select do |item| item.is_a?(Hypertube::Utils::Command) && item.command_type == Hypertube::Utils::CommandType::VALUE_FOR_UPDATE end return response_command if commands_to_update.empty? unless @is_stateless @materialization_mutex.synchronize do commands_to_update.each do |cmd| next if cmd.payload.nil? || cmd.payload.length < 2 context_guid = cmd.payload[0].to_s next if context_guid.empty? inv_ctx = nil self.class.instances_to_be_materialized_mutex.synchronize do inv_ctx = self.class.instances_to_be_materialized.delete(context_guid) end next if inv_ctx.nil? instance_guid = cmd.payload[1] inv_ctx.instance_variable_set( :@current_command, Hypertube::Utils::Command.new( @runtime_name, Hypertube::Utils::CommandType::REFERENCE, [instance_guid] ) ) inv_ctx.instance_variable_set(:@is_executed, true) end end end updated_payload = payload.reject do |item| item.is_a?(Hypertube::Utils::Command) && item.command_type == Hypertube::Utils::CommandType::VALUE_FOR_UPDATE end Hypertube::Utils::Command.new( response_command.runtime_name, response_command.command_type, updated_payload ) end |
#register_for_update ⇒ Hypertube::Sdk::InvocationContext
Registers the current context for updates by wrapping it in a REGISTER_FOR_UPDATE command.
433 434 435 436 437 438 439 440 441 442 443 444 |
# File 'lib/hypertube-ruby-sdk/sdk/invocation_context.rb', line 433 def register_for_update local_command = Hypertube::Utils::Command.new( @runtime_name, Hypertube::Utils::CommandType::REGISTER_FOR_UPDATE, [@guid] ) @current_command = build_command(local_command) self.class.instances_to_be_materialized_mutex.synchronize do self.class.instances_to_be_materialized[@guid] = self end self end |
#retrieve_array ⇒ Object, Array
Retrieves an array from the target runtime. Retrieves an array from the target runtime.
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 |
# File 'lib/hypertube-ruby-sdk/sdk/invocation_context.rb', line 386 def retrieve_array array_inv_ctx = self unless @is_stateless retrieve_array_command = Hypertube::Utils::Command.new(@runtime_name, Hypertube::Utils::CommandType::RETRIEVE_ARRAY, []) local_inv_ctx = Hypertube::Sdk::InvocationContext.new( @runtime_name, @connection_type, @connection_data, build_command(retrieve_array_command) ) array_inv_ctx = local_inv_ctx.execute end payload = array_inv_ctx.current_command.payload return [] if payload.empty? if payload[0].is_a?(Hypertube::Utils::Command) invocation_contexts = Array.new(payload.length) payload.each_with_index do |item, i| invocation_contexts[i] = Hypertube::Sdk::InvocationContext.new( @runtime_name, @connection_type, @connection_data, item, @is_executed, @is_stateless ) end return invocation_contexts end payload end |
#set_index(indexes, value) ⇒ Hypertube::Sdk::InvocationContext
Sets the value at a specific index in an array in the target runtime.
287 288 289 290 |
# File 'lib/hypertube-ruby-sdk/sdk/invocation_context.rb', line 287 def set_index(indexes, value) local_command = Hypertube::Utils::Command.new(@runtime_name, Hypertube::Utils::CommandType::ARRAY_SET_ITEM, [indexes, value]) build_invocation_context(local_command) end |
#set_instance_field(field_name, value) ⇒ Hypertube::Sdk::InvocationContext
Sets the value of an instance field in the target runtime.
263 264 265 266 267 268 269 270 271 |
# File 'lib/hypertube-ruby-sdk/sdk/invocation_context.rb', line 263 def set_instance_field(field_name, value) local_command = Hypertube::Utils::Command.new(@runtime_name, Hypertube::Utils::CommandType::SET_INSTANCE_FIELD, [field_name, value]) new_command = build_command(local_command) if @is_stateless @current_command = new_command return self end Hypertube::Sdk::InvocationContext.new(@runtime_name, @connection_type, @connection_data, new_command, @is_executed, @is_stateless) end |
#set_static_field(field_name, value) ⇒ Hypertube::Sdk::InvocationContext
Sets the value of a static field in the target runtime.
223 224 225 226 |
# File 'lib/hypertube-ruby-sdk/sdk/invocation_context.rb', line 223 def set_static_field(field_name, value) local_command = Hypertube::Utils::Command.new(@runtime_name, Hypertube::Utils::CommandType::SET_STATIC_FIELD, [field_name, value]) build_invocation_context(local_command) end |