Module: AMF

Defined in:
lib/amf.rb,
lib/amf/ext.rb,
lib/amf/pure.rb,
lib/amf/pure/serializer.rb,
lib/amf/pure/deserializer.rb,
lib/amf/pure/amf_constants.rb,
lib/amf/common/hash_with_type.rb,
lib/amf/pure/errors/amf_error.rb,
lib/amf/pure/mapping/mapping_set.rb,
lib/amf/pure/mapping/class_mapper.rb,
lib/amf/pure/helpers/cache_objects.rb,
lib/amf/pure/helpers/cache_strings.rb,
lib/amf/pure/helpers/io_helper_base.rb,
lib/amf/pure/helpers/io_helper_read.rb,
lib/amf/pure/helpers/io_helper_write.rb,
lib/amf/pure/errors/amf_error_incomplete.rb

Overview

AMF is a full featured AMF3 serializer/deserializer with support for bi-directional other language to ruby class mapping, custom serialization and mapping, remoting gateway helpers that follow AMF3 messaging specs, and a suite of specs to ensure adherence to the specification documents put out by Adobe. If the C components compile, then RocketAMF automatically takes advantage of them to provide a substantial performance benefit. In addition, RocketAMF is fully compatible with Ruby 2.0, 2.1.

Performance

# 100.000 objects
# Ruby 2.0
Testing pure AMF3:
  minimum serialize time: 49.294496s
  minimum deserialize time: 6.600238s

Example

test_object =

{
   first_name: "Greg",
   last_name:  "House"
}

data = AMF::Root.serialize(test_object)

restored_object = AMF::Root.serialize(data)

Mapping Classes Between Other language and Ruby

RocketAMF provides a simple class mapping tool to facilitate serialization and deserialization of typed objects. Refer to the documentation of RocketAMF::ClassMapping for more details. If the provided class mapping tool is not sufficient for your needs, you also have the option to replace it with a class mapper of your own devising that matches the documented API.

Advanced Serialization (encode_amf and IExternalizable)

RocketAMF provides some additional functionality to support advanced serialization techniques. If you define an encode_amf method on your object, it will get called during serialization. It is passed a single argument, the serializer, and it can use the serializer stream, the serialize method, the write_array method, the write_object method, and the serializer version. Below is a simple example that uses write_object to customize the property hash that is used for serialization.

Example:

class TestObject
  def encode_amf serializer
    serializer.write_object self, @attributes
  end
end

If you plan on using the serialize method, make sure to pass in the current serializer version, or you could create a message that cannot be deserialized.

Example:

class VariableObject
  def encode_amf serializer
      serializer.serialize(false)
  end
end

Defined Under Namespace

Modules: AMFConstants, Ext, Pure Classes: AMFError, AMFErrorIncomplete, ClassMapper, HashWithType, MappingSet, Root

Constant Summary collapse

Deserializer =

:stopdoc: Import serializer/deserializer

AMF::Pure::Deserializer
Serializer =
AMF::Pure::Serializer