Sha256: 3909fba89c41970140b30a7154f40e00211afdd9bbbb17297347d194341b943e

Contents?: true

Size: 710 Bytes

Versions: 4

Compression:

Stored size: 710 Bytes

Contents

# frozen_string_literal: true

module GrapeSwagger
  module DocMethods
    class TagNameDescription
      class << self
        def build(paths)
          paths.values.each_with_object([]) do |path, memo|
            tags = path.values.first[:tags]

            case tags
            when String
              memo << build_memo(tags)
            when Array
              path.values.first[:tags].each do |tag|
                memo << build_memo(tag)
              end
            end
          end.uniq
        end

        private

        def build_memo(tag)
          {
            name: tag,
            description: "Operations about #{tag.pluralize}"
          }
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
grape-swagger-0.27.3 lib/grape-swagger/doc_methods/tag_name_description.rb
grape-swagger-0.27.2 lib/grape-swagger/doc_methods/tag_name_description.rb
grape-swagger-0.27.1 lib/grape-swagger/doc_methods/tag_name_description.rb
grape-swagger-0.27.0 lib/grape-swagger/doc_methods/tag_name_description.rb