Module: MsRest::Serialization

Included in:
JSONable
Defined in:
lib/ms_rest/serialization.rb,
lib/ms_rest.rb

Overview

Base module for Ruby serialization and deserialization.

Provides methods to serialize Ruby object into Ruby Hash and to deserialize Ruby Hash into Ruby object.

Defined Under Namespace

Classes: Serialization

Instance Method Summary collapse

Instance Method Details

#deserialize(mapper, response_body) ⇒ Object

Deserialize the response from the server using the mapper.

Parameters:

  • mapper (Hash)

    Ruby Hash object to represent expected structure of the response_body.

  • response_body (Hash)

    Ruby Hash object to deserialize.

  • object_name (String)

    Name of the deserialized object.



18
19
20
# File 'lib/ms_rest/serialization.rb', line 18

def deserialize(mapper, response_body)
  build_serializer.deserialize(mapper, response_body)
end

#serialize(mapper, object) ⇒ Object

Serialize the Ruby object into Ruby Hash to send it to the server using the mapper.

Parameters:

  • mapper (Hash)

    Ruby Hash object to represent expected structure of the object.

  • object (Object)

    Ruby object to serialize.

  • object_name (String)

    Name of the serialized object.



29
30
31
# File 'lib/ms_rest/serialization.rb', line 29

def serialize(mapper, object)
  build_serializer.serialize(mapper, object)
end