Class: Net::HTTP::StructuredFieldValues::Serializer
- Inherits:
-
Object
- Object
- Net::HTTP::StructuredFieldValues::Serializer
- Defined in:
- lib/net/http/structured_field_values/serializer.rb
Overview
RFC8941 compliant serializer which serializes Ruby objects into HTTP fields.
Defined Under Namespace
Classes: SerializationError
Class Method Summary collapse
-
.serialize(obj) ⇒ String
Serializes given object.
-
.serialize_as_inner_list(input) ⇒ String
Serializes input as Inner List.
Instance Method Summary collapse
-
#initialize ⇒ Serializer
constructor
A new instance of Serializer.
- #serialize(obj) ⇒ String
-
#serialize_as_inner_list(input) ⇒ String
Serializes input as Inner List.
Constructor Details
#initialize ⇒ Serializer
Returns a new instance of Serializer.
12 13 14 |
# File 'lib/net/http/structured_field_values/serializer.rb', line 12 def initialize @result = +'' end |
Class Method Details
.serialize(obj) ⇒ String
Serializes given object.
37 38 39 |
# File 'lib/net/http/structured_field_values/serializer.rb', line 37 def self.serialize(obj) new.serialize(obj) end |
.serialize_as_inner_list(input) ⇒ String
Note:
Use of this method breaks RFC8941.
Serializes input as Inner List.
59 60 61 |
# File 'lib/net/http/structured_field_values/serializer.rb', line 59 def self.serialize_as_inner_list(input) new.serialize_as_inner_list(input) end |
Instance Method Details
#serialize(obj) ⇒ String
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/net/http/structured_field_values/serializer.rb', line 17 def serialize(obj) case obj when Array serialize_list(obj) when Hash serialize_dictionary(obj) else value, params = unpack_parameterized_value(obj) serialize_item(value, params) end result.encode(Encoding::ASCII) end |
#serialize_as_inner_list(input) ⇒ String
Note:
Use of this method breaks RFC8941.
Serializes input as Inner List.
47 48 49 50 51 |
# File 'lib/net/http/structured_field_values/serializer.rb', line 47 def serialize_as_inner_list(input) arr, params = unpack_parameterized_value(input) serialize_inner_list(arr, params) result.encode(Encoding::ASCII) end |