Sha256: 2ca78b1fcc0763c41de6b329d0ecac852430efc06891b15126e0d2e202f6b204

Contents?: true

Size: 739 Bytes

Versions: 3

Compression:

Stored size: 739 Bytes

Contents

module GrapeSwagger
  module DocMethods
    class OperationId
      class << self
        def build(route, path = nil)
          verb = route.request_method.to_s.downcase

          operation = manipulate(path) unless path.nil?

          "#{verb}#{operation}"
        end

        def manipulate(path)
          operation = path.split('/').map(&:capitalize).join
          operation.gsub!(/\-(\w)/, &:upcase).delete!('-') if operation.include?('-')
          operation.gsub!(/\_(\w)/, &:upcase).delete!('_') if operation.include?('_')
          if path.include?('{')
            operation.gsub!(/\{(\w)/, &:upcase)
            operation.delete!('{').delete!('}')
          end

          operation
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
grape-swagger-0.22.0 lib/grape-swagger/doc_methods/operation_id.rb
grape-swagger-0.21.0 lib/grape-swagger/doc_methods/operation_id.rb
grape-swagger-0.20.3 lib/grape-swagger/doc_methods/operation_id.rb