Module: Cuprum::Rails::Responders::Serialization
- Included in:
- JsonResponder
- Defined in:
- lib/cuprum/rails/responders/serialization.rb
Overview
Implements serializing a result value into response data.
Instance Attribute Summary collapse
-
#serializers ⇒ Hash<Class, Object>
readonly
The serializers for converting result values into serialized data.
Instance Method Summary collapse
- #initialize(serializers:, **options) ⇒ Object
-
#serialize(object) ⇒ Object
Converts a result value into a serialized data structure.
Instance Attribute Details
#serializers ⇒ Hash<Class, Object> (readonly)
Returns The serializers for converting result values into serialized data.
21 22 23 |
# File 'lib/cuprum/rails/responders/serialization.rb', line 21 def serializers @serializers end |
Instance Method Details
#initialize(serializers:, **options) ⇒ Object
13 14 15 16 17 |
# File 'lib/cuprum/rails/responders/serialization.rb', line 13 def initialize(serializers:, **) super(**) @serializers = serializers end |
#serialize(object) ⇒ Object
Converts a result value into a serialized data structure.
28 29 30 31 32 33 34 35 36 |
# File 'lib/cuprum/rails/responders/serialization.rb', line 28 def serialize(object) context = Cuprum::Rails::Serializers::Context.new( serializers: serializers ) Cuprum::Rails::Serializers::BaseSerializer .instance .call(object, context: context) end |