Class: AMF::Pure::Serializer
- Inherits:
-
Object
- Object
- AMF::Pure::Serializer
- Includes:
- AMFConstants, IOHelperWrite
- Defined in:
- lib/amf/pure/serializer.rb
Overview
Pure ruby serializer for AMF3
Constant Summary
Constants included from AMFConstants
AMFConstants::AMF3_CLOSE_DYNAMIC_ARRAY, AMFConstants::AMF3_CLOSE_DYNAMIC_OBJECT, AMFConstants::AMF3_EMPTY_STRING, AMFConstants::AMF3_MARKER_ARRAY, AMFConstants::AMF3_MARKER_BYTE_ARRAY, AMFConstants::AMF3_MARKER_DATE, AMFConstants::AMF3_MARKER_DICTIONARY, AMFConstants::AMF3_MARKER_DOUBLE, AMFConstants::AMF3_MARKER_FALSE, AMFConstants::AMF3_MARKER_INTEGER, AMFConstants::AMF3_MARKER_NULL, AMFConstants::AMF3_MARKER_OBJECT, AMFConstants::AMF3_MARKER_STRING, AMFConstants::AMF3_MARKER_TRUE, AMFConstants::AMF3_MARKER_UNDEFINED, AMFConstants::AMF3_MARKER_VECTOR_DOUBLE, AMFConstants::AMF3_MARKER_VECTOR_INT, AMFConstants::AMF3_MARKER_VECTOR_OBJECT, AMFConstants::AMF3_MARKER_VECTOR_UINT, AMFConstants::AMF3_MARKER_XML, AMFConstants::AMF3_MARKER_XML_DOC, AMFConstants::INTEGER_MAX, AMFConstants::INTEGER_MIN, AMFConstants::MIN_INT_2_BYTE, AMFConstants::MIN_INT_3_BYTE, AMFConstants::MIN_INT_4_BYTE
Instance Method Summary collapse
-
#initialize(class_mapper) ⇒ Serializer
constructor
A new instance of Serializer.
-
#serialize(obj) ⇒ Object
Serialize the given object using AMF3.
- #write_array(value) ⇒ Object
- #write_object(obj, props = nil, traits = nil) ⇒ Object
Methods included from IOHelperWrite
#pack_double, #pack_int16_network, #pack_int8, #pack_integer, #pack_word32_network
Methods included from IOHelperBase
#byte_order, #byte_order_little?
Constructor Details
#initialize(class_mapper) ⇒ Serializer
Returns a new instance of Serializer.
26 27 28 29 30 |
# File 'lib/amf/pure/serializer.rb', line 26 def initialize(class_mapper) @class_mapper = class_mapper @stream = '' @depth = 0 end |
Instance Method Details
#serialize(obj) ⇒ Object
Serialize the given object using AMF3. Can be called from inside encode_amf.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/amf/pure/serializer.rb', line 34 def serialize(obj) # Initialize caches if @depth == 0 @cache_strings = CacheStrings.new @cache_objects = CacheObjects.new @cache_traits = CacheStrings.new end @depth += 1 # Perform serialization amf3_serialize(obj) # Cleanup @depth -= 1 if @depth == 0 @cache_strings = nil @cache_objects = nil @cache_traits = nil end @stream end |
#write_array(value) ⇒ Object
90 91 92 |
# File 'lib/amf/pure/serializer.rb', line 90 def write_array(value) amf3_write_array(value) end |
#write_object(obj, props = nil, traits = nil) ⇒ Object
99 100 101 |
# File 'lib/amf/pure/serializer.rb', line 99 def write_object(obj, props = nil, traits = nil) amf3_write_object(obj, props, traits) end |