Sha256: 87884150f07fe9ebfedb1ed61d14e83fc828e01c6985fad086cded55c819cb2d

Contents?: true

Size: 928 Bytes

Versions: 40

Compression:

Stored size: 928 Bytes

Contents

require_relative 'abstract_command_handler'

class SetInstanceFieldHandler < AbstractCommandHandler
  def initialize
    @required_parameters_count = 3
  end

  def process(command)
    return set_instance_field(command)
  end

  def set_instance_field(command)
    begin
      if command.payload.length < @required_parameters_count
        raise ArgumentError.new "Set Instance Field parameters mismatch"
      end
  
      merged_value = '@' + command.payload[1]
      begin
        command.payload[0].instance_variable_set(merged_value, command.payload[2])
      rescue NameError
        fields = command.payload[0].instance_variables
        message = "Field #{command.payload[1]} not found in class #{command.payload[0].class.name}. Available fields:\n"
        fields.each { |field_iter| message += "#{field_iter} \n" }
        raise Exception, message
      end
    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/set_instance_field_handler.rb
javonet-ruby-sdk-2.5.7 lib/javonet-ruby-sdk/Binaries/Ruby/Linux/X64/core/handler/set_instance_field_handler.rb
javonet-ruby-sdk-2.5.6 lib/javonet-ruby-sdk/Binaries/Ruby/MacOs/X64/core/handler/set_instance_field_handler.rb
javonet-ruby-sdk-2.5.6 lib/javonet-ruby-sdk/Binaries/Ruby/Linux/X64/core/handler/set_instance_field_handler.rb
javonet-ruby-sdk-2.5.5 lib/javonet-ruby-sdk/Binaries/Ruby/Linux/X64/core/handler/set_instance_field_handler.rb
javonet-ruby-sdk-2.5.5 lib/javonet-ruby-sdk/Binaries/Ruby/MacOs/X64/core/handler/set_instance_field_handler.rb
javonet-ruby-sdk-2.5.4 lib/javonet-ruby-sdk/Binaries/Ruby/MacOs/X64/core/handler/set_instance_field_handler.rb
javonet-ruby-sdk-2.5.4 lib/javonet-ruby-sdk/Binaries/Ruby/Linux/X64/core/handler/set_instance_field_handler.rb
javonet-ruby-sdk-2.5.3 lib/javonet-ruby-sdk/Binaries/Ruby/MacOs/X64/core/handler/set_instance_field_handler.rb
javonet-ruby-sdk-2.5.3 lib/javonet-ruby-sdk/Binaries/Ruby/Linux/X64/core/handler/set_instance_field_handler.rb
javonet-ruby-sdk-2.5.2 lib/javonet-ruby-sdk/Binaries/Ruby/MacOs/X64/core/handler/set_instance_field_handler.rb
javonet-ruby-sdk-2.5.2 lib/javonet-ruby-sdk/Binaries/Ruby/Linux/X64/core/handler/set_instance_field_handler.rb
javonet-ruby-sdk-2.5.1 lib/javonet-ruby-sdk/Binaries/Ruby/MacOs/X64/core/handler/set_instance_field_handler.rb
javonet-ruby-sdk-2.5.1 lib/javonet-ruby-sdk/Binaries/Ruby/Linux/X64/core/handler/set_instance_field_handler.rb
javonet-ruby-sdk-2.5.0 lib/javonet-ruby-sdk/Binaries/Ruby/MacOs/X64/core/handler/set_instance_field_handler.rb
javonet-ruby-sdk-2.5.0 lib/javonet-ruby-sdk/Binaries/Ruby/Linux/X64/core/handler/set_instance_field_handler.rb
javonet-ruby-sdk-2.4.11 lib/javonet-ruby-sdk/Binaries/Ruby/MacOs/X64/core/handler/set_instance_field_handler.rb
javonet-ruby-sdk-2.4.11 lib/javonet-ruby-sdk/Binaries/Ruby/Linux/X64/core/handler/set_instance_field_handler.rb
javonet-ruby-sdk-2.4.10 lib/javonet-ruby-sdk/Binaries/Ruby/Linux/X64/core/handler/set_instance_field_handler.rb
javonet-ruby-sdk-2.4.10 lib/javonet-ruby-sdk/Binaries/Ruby/MacOs/X64/core/handler/set_instance_field_handler.rb