Sha256: 48961208e70aa46b8a9fadb115acbd2d57fb8a6fddb9181c7fb68d8de12f8bac

Contents?: true

Size: 757 Bytes

Versions: 18

Compression:

Stored size: 757 Bytes

Contents

module SoberSwag
  module Serializer
    ##
    # Make a serialize of arrays out of a serializer of the elements
    class Array < Base
      def initialize(element_serializer)
        @element_serializer = element_serializer
      end

      def lazy_type?
        @element_serializer.lazy_type?
      end

      def lazy_type
        SoberSwag::Types::Array.of(@element_serializer.lazy_type)
      end

      def finalize_lazy_type!
        @element_serializer.finalize_lazy_type!
      end

      attr_reader :element_serializer

      def serialize(object, options = {})
        object.map { |a| element_serializer.serialize(a, options) }
      end

      def type
        SoberSwag::Types::Array.of(element_serializer.type)
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
sober_swag-0.19.0 lib/sober_swag/serializer/array.rb
sober_swag-0.18.0 lib/sober_swag/serializer/array.rb
sober_swag-0.17.0 lib/sober_swag/serializer/array.rb
sober_swag-0.16.0 lib/sober_swag/serializer/array.rb
sober_swag-0.15.0 lib/sober_swag/serializer/array.rb
sober_swag-0.14.0 lib/sober_swag/serializer/array.rb
sober_swag-0.13.0 lib/sober_swag/serializer/array.rb
sober_swag-0.12.0 lib/sober_swag/serializer/array.rb
sober_swag-0.11.0 lib/sober_swag/serializer/array.rb
sober_swag-0.10.0 lib/sober_swag/serializer/array.rb
sober_swag-0.9.0 lib/sober_swag/serializer/array.rb
sober_swag-0.8.0 lib/sober_swag/serializer/array.rb
sober_swag-0.7.0 lib/sober_swag/serializer/array.rb
sober_swag-0.6.0 lib/sober_swag/serializer/array.rb
sober_swag-0.5.0 lib/sober_swag/serializer/array.rb
sober_swag-0.4.0 lib/sober_swag/serializer/array.rb
sober_swag-0.3.0 lib/sober_swag/serializer/array.rb
sober_swag-0.2.0 lib/sober_swag/serializer/array.rb