Class: Tarantool::Requests::Update
- Inherits:
-
Tarantool::Request
- Object
- Tarantool::Request
- Tarantool::Requests::Update
- Defined in:
- lib/tarantool/requests/update.rb
Constant Summary collapse
- OP_CODES =
{ set: 0, add: 1, and: 2, or: 3, xor: 4, splice: 5 }
Instance Attribute Summary collapse
-
#flags ⇒ Object
readonly
Returns the value of attribute flags.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#ops ⇒ Object
readonly
Returns the value of attribute ops.
Attributes inherited from Tarantool::Request
#args, #params, #space, #space_no
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Tarantool::Request
#connection, #initialize, #make_packet, #make_response, pack_field, pack_tuple, #perform, #request_id, request_type, #response_params
Constructor Details
This class inherits a constructor from Tarantool::Request
Instance Attribute Details
#flags ⇒ Object (readonly)
Returns the value of attribute flags.
19 20 21 |
# File 'lib/tarantool/requests/update.rb', line 19 def flags @flags end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
19 20 21 |
# File 'lib/tarantool/requests/update.rb', line 19 def key @key end |
#ops ⇒ Object (readonly)
Returns the value of attribute ops.
19 20 21 |
# File 'lib/tarantool/requests/update.rb', line 19 def ops @ops end |
Class Method Details
.pack_ops(ops) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/tarantool/requests/update.rb', line 8 def self.pack_ops(ops) ops.map do |op| raise ArgumentError.new('Operation should be array of size 3') unless op.size == 3 field_no, op_symbol, op_arg = op op_code = OP_CODES[op_symbol] || raise(ArgumentError.new("Unsupported operation symbol '#{op_symbol}'")) [field_no, op_code].pack('LC') + self.pack_field(op_arg) end.join end |
Instance Method Details
#make_body ⇒ Object
27 28 29 30 31 32 |
# File 'lib/tarantool/requests/update.rb', line 27 def make_body [space_no, flags].pack('LL') + self.class.pack_tuple(key) + [ops.size].pack('L') + self.class.pack_ops(ops) end |
#parse_args ⇒ Object
20 21 22 23 24 25 |
# File 'lib/tarantool/requests/update.rb', line 20 def parse_args @flags = params[:return_tuple] ? 1 : 0 @key = params[:key] || args.first @ops = params[:ops] raise ArgumentError.new('Key is required') unless key end |