Sha256: b6776f48aed67fcc477f2682b3d0b6611408966130155ea8c9ec44c847f35c67

Contents?: true

Size: 629 Bytes

Versions: 9

Compression:

Stored size: 629 Bytes

Contents

module SoberSwag
  class Types
    ##
    # An array that will be parsed from comma-separated values in a string, if given a string.
    module CommaArray
      ##
      # Get a parser that will parse comma-separated values of another type.
      # @param other [Class] a swagger-able type to parse into
      # @return [SoberSwag::Types::CommaArray]
      def self.of(other)
        SoberSwag::Types::Array.of(other).constructor { |val|
          if val.is_a?(::String)
            val.split(',').map(&:strip)
          else
            val
          end
        }.meta(style: :form, explode: false)
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
sober_swag-0.25.2 lib/sober_swag/types/comma_array.rb
sober_swag-0.25.1 lib/sober_swag/types/comma_array.rb
sober_swag-0.25.0 lib/sober_swag/types/comma_array.rb
sober_swag-0.24.1 lib/sober_swag/types/comma_array.rb
sober_swag-0.24.0 lib/sober_swag/types/comma_array.rb
sober_swag-0.23.0 lib/sober_swag/types/comma_array.rb
sober_swag-0.22.0 lib/sober_swag/types/comma_array.rb
sober_swag-0.21.0 lib/sober_swag/types/comma_array.rb
sober_swag-0.20.0 lib/sober_swag/types/comma_array.rb