Class: Tair::PutResponse

Inherits:
Response show all
Defined in:
lib/tair/operation/put.rb

Defined Under Namespace

Classes: Body, FailureData, SuccessData

Constant Summary collapse

TAIR_TYPE_INT =

tair serialize type

1
TAIR_TYPE_STRING =
2
TAIR_TYPE_BOOL =
3
TAIR_TYPE_LONG =
4
TAIR_TYPE_DATE =
5
TAIR_TYPE_BYTE =
6
TAIR_TYPE_FLOAT =
7
TAIR_TYPE_DOUBLE =
8
TAIR_TYPE_BYTEARRAY =
9
TAIR_TYPE_SERIALIZE =
10
TAIR_TYPE_INCDATA =
11
TAIR_TYPE_MIXEDKEY =
12

Instance Attribute Summary

Attributes inherited from Response

#body, #raw_text

Instance Method Summary collapse

Methods inherited from Response

#initialize

Constructor Details

This class inherits a constructor from Tair::Response

Instance Method Details

#decodeObject



89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/tair/operation/put.rb', line 89

def decode
  body = Body.read(@body)
  if body.success?
    data = body.succ_data
    type, raw = data.value_type >> 1, data.raw_value
    @value =  case type
                when TAIR_TYPE_INT      then BinData::Double.read(raw).to_i
                when TAIR_TYPE_STRING   then raw.to_s
              end
  else
    nil
  end
end

#success?Boolean

Returns:

  • (Boolean)


81
82
83
84
85
86
# File 'lib/tair/operation/put.rb', line 81

def success?
  return true

  decode
  @value
end