Sha256: 7c476e8802dc8f3f404eda69e0ef56123859a79ca9a9b9204f3737ad19d08660
Contents?: true
Size: 809 Bytes
Versions: 1
Compression:
Stored size: 809 Bytes
Contents
module SoberSwag module Serializer ## # A new serializer by mapping over the serialization function class Mapped < Base def initialize(base, map_f) @base = base @map_f = map_f end def serialize(object, options) @base.serialize(@map_f.call(object), options) end def lazy_type? @base.lazy_type? end def lazy_type @base.lazy_type end def finalize_lazy_type! @base.finalize_lazy_type! end def type @base.type end ## # I have no freaking clue if ruby optimizes proc composition, # but we at least save some node traversals here def via_map(&block) SoberSwag::Serializer::Mapped.new(@base, @map_f >> block) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sober_swag-0.2.0 | lib/sober_swag/serializer/mapped.rb |