class SoberSwag::Serializer::Mapped
A new serializer by mapping over the serialization function
Attributes
base[R]
@return [SoberSwag::Serializer::Base] serializer to use after mapping
map_f[R]
@return [Proc, Lambda, call] function to use before serialization
Public Class Methods
new(base, map_f)
click to toggle source
Create a new mapped serializer. @param base [SoberSwag::Serializer::Base] a serializer to use after mapping @param map_f
[Proc,Lambda] a mapping function to use before serialization
# File lib/sober_swag/serializer/mapped.rb, line 10 def initialize(base, map_f) @base = base @map_f = map_f end
Public Instance Methods
finalize_lazy_type!()
click to toggle source
# File lib/sober_swag/serializer/mapped.rb, line 34 def finalize_lazy_type! @base.finalize_lazy_type! end
lazy_type()
click to toggle source
# File lib/sober_swag/serializer/mapped.rb, line 30 def lazy_type @base.lazy_type end
lazy_type?()
click to toggle source
# File lib/sober_swag/serializer/mapped.rb, line 26 def lazy_type? @base.lazy_type? end
serialize(object, options = {})
click to toggle source
# File lib/sober_swag/serializer/mapped.rb, line 22 def serialize(object, options = {}) @base.serialize(@map_f.call(object), options) end
type()
click to toggle source
# File lib/sober_swag/serializer/mapped.rb, line 38 def type @base.type end