Class: Aerospike::Value
- Inherits:
-
Object
- Object
- Aerospike::Value
- Defined in:
- lib/aerospike/value/value.rb
Overview
Polymorphic value classes used to efficiently serialize objects into the wire protocol.
Direct Known Subclasses
BytesValue, IntegerValue, ListValue, MapValue, NullValue, StringValue
Constant Summary collapse
Class Method Summary collapse
Class Method Details
.get_packer ⇒ Object
33 34 35 36 37 |
# File 'lib/aerospike/value/value.rb', line 33 def self.get_packer res = @@packer_pool.poll res.clear res end |
.of(value) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/aerospike/value/value.rb', line 43 def self.of(value) case value when nil res = NullValue.new when Integer if value < 2**63 res = IntegerValue.new(value) else # big nums > 2**63 are not supported raise Aerospike::Exceptions::Aerospike.new(Aerospike::ResultCode::TYPE_NOT_SUPPORTED, "Value type #{value.class} not supported.") end when String res = StringValue.new(value) when Symbol res = StringValue.new(value.to_s) when Value res = value when Hash res = MapValue.new(value) when Array res = ListValue.new(value) else # throw an exception for anything that is not supported. raise Aerospike::Exceptions::Aerospike.new(Aerospike::ResultCode::TYPE_NOT_SUPPORTED, "Value type #{value.class} not supported.") end res end |
.put_packer(packer) ⇒ Object
39 40 41 |
# File 'lib/aerospike/value/value.rb', line 39 def self.put_packer(packer) @@packer_pool.offer(packer) end |