Sha256: 070e0621e64066100ab4adf6268072c966d34f55820954deebb1f7566209355d

Contents?: true

Size: 612 Bytes

Versions: 12

Compression:

Stored size: 612 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

      attr_reader :base, :map_f

      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
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
sober_swag-0.19.0 lib/sober_swag/serializer/mapped.rb
sober_swag-0.18.0 lib/sober_swag/serializer/mapped.rb
sober_swag-0.17.0 lib/sober_swag/serializer/mapped.rb
sober_swag-0.16.0 lib/sober_swag/serializer/mapped.rb
sober_swag-0.15.0 lib/sober_swag/serializer/mapped.rb
sober_swag-0.14.0 lib/sober_swag/serializer/mapped.rb
sober_swag-0.13.0 lib/sober_swag/serializer/mapped.rb
sober_swag-0.12.0 lib/sober_swag/serializer/mapped.rb
sober_swag-0.11.0 lib/sober_swag/serializer/mapped.rb
sober_swag-0.10.0 lib/sober_swag/serializer/mapped.rb
sober_swag-0.9.0 lib/sober_swag/serializer/mapped.rb
sober_swag-0.8.0 lib/sober_swag/serializer/mapped.rb