Module: Synapse::Upcasting::Upcaster

Extended by:
ActiveSupport::Concern
Included in:
SingleUpcaster
Defined in:
lib/synapse/upcasting/upcaster.rb

Overview

Represents a mechanism for converting deprecated serialized objects into the current format used by the application. If the serializer itself is not able to cope with the changed formats, an upcaster provides flexibility for more complex structural transformations.

Upcasters work on intermediate representations of the object to upcast. In most cases, this representation is an object structure of some kind. The serializer is responsible for converting the intermediate representation form to one that is compatible with the upcaster.

For performance reasons, it is advisable to ensure that all upcasters in the same chain use the same intermediate representation type.

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#can_upcast?(serialized_type) ⇒ Boolean

This method is abstract.

Returns true if this upcaster is capable of upcasting the given type

Parameters:

  • serialized_type (SerializedType)

Returns:

  • (Boolean)


33
# File 'lib/synapse/upcasting/upcaster.rb', line 33

def can_upcast?(serialized_type); end

#upcast(intermediate, expected_types, upcast_context) ⇒ Array<SerializedObject>

This method is abstract.

Upcasts a given serialized object to zero or more upcast objects

The types of the upcast objects should match the same length and order of the given array of upcast types.

Parameters:

  • intermediate (SerialiedObject)
  • expected_types (Array<SerializedType>)
  • upcast_context (UpcastingContext)

Returns:

  • (Array<SerializedObject>)


45
# File 'lib/synapse/upcasting/upcaster.rb', line 45

def upcast(intermediate, expected_types, upcast_context); end

#upcast_type(serialized_type) ⇒ Array<SerializedType>

This method is abstract.

Upcasts a given serialized type to zero or more upcast types

Parameters:

  • serialized_type (SerializedType)

Returns:

  • (Array<SerializedType>)


52
# File 'lib/synapse/upcasting/upcaster.rb', line 52

def upcast_type(serialized_type); end