Class: Synapse::Configuration::SerializerDefinitionBuilder

Inherits:
DefinitionBuilder show all
Defined in:
lib/synapse/configuration/component/serialization/serializer.rb

Overview

Definition builder used to create and configure serializers

Examples:

The minimum possible to create a serializer (defaults to marshal)

serializer

Use a specific serializer and converter_factory

serializer :alt_serializer do
  use_ox
  use_converter_factory :alt_converter_factory
end

Instance Attribute Summary

Attributes inherited from DefinitionBuilder

#id

Instance Method Summary collapse

Methods inherited from DefinitionBuilder

#anonymous, #as_prototype, #as_singleton, build, #build_composite, #build_definition, #clear_tags, #identified_by, #initialize, #register_definition, #replace_tags, #tag, #use_factory, #use_instance

Constructor Details

This class inherits a constructor from Synapse::Configuration::DefinitionBuilder

Instance Method Details

#use_attributeundefined

Selects a serializer that uses attributes (ActiveModel, Virtus, etc.)

Returns:

  • (undefined)

See Also:



18
19
20
# File 'lib/synapse/configuration/component/serialization/serializer.rb', line 18

def use_attribute
  @serializer_type = Serialization::AttributeSerializer
end

#use_converter_factory(converter_factory) ⇒ undefined

Changes the converter factory

Parameters:

  • converter_factory (Symbol)

Returns:

  • (undefined)

See Also:



51
52
53
# File 'lib/synapse/configuration/component/serialization/serializer.rb', line 51

def use_converter_factory(converter_factory)
  @converter_factory = converter_factory
end

#use_deserialize_options(deserialize_options) ⇒ undefined

Changes the options to use during deserialization; note that these are serializer-specific and that not all serializers support options.

Parameters:

  • deserialize_options (Hash)

Returns:

  • (undefined)


69
70
71
# File 'lib/synapse/configuration/component/serialization/serializer.rb', line 69

def use_deserialize_options(deserialize_options)
  @deserialize_options = deserialize_options
end

#use_marshalundefined

Selects a serializer that uses the Ruby marshaling library

Returns:

  • (undefined)

See Also:



26
27
28
# File 'lib/synapse/configuration/component/serialization/serializer.rb', line 26

def use_marshal
  @serializer_type = Serialization::MarshalSerializer
end

#use_ojundefined

Selects a serializer that uses the Optimized JSON (Oj) serialization library

Returns:

  • (undefined)

See Also:



34
35
36
# File 'lib/synapse/configuration/component/serialization/serializer.rb', line 34

def use_oj
  @serializer_type = Serialization::OjSerializer
end

#use_oxundefined

Selects a serializer that uses the Optimized XML (Ox) serialization library

Returns:

  • (undefined)

See Also:



42
43
44
# File 'lib/synapse/configuration/component/serialization/serializer.rb', line 42

def use_ox
  @serializer_type = Serialization::OxSerializer
end

#use_serialize_options(serialize_options) ⇒ undefined

Changes the options to use during serialization; note that these are serializer-specific and that not all serializers support options.

Parameters:

  • serialize_options (Hash)

Returns:

  • (undefined)


60
61
62
# File 'lib/synapse/configuration/component/serialization/serializer.rb', line 60

def use_serialize_options(serialize_options)
  @serialize_options = serialize_options
end