class RspecApiDocs::Renderer::JSONRenderer::Name

Public Class Methods

call(name:, scope:) click to toggle source
# File lib/rspec_api_docs/formatter/renderer/json_renderer/name.rb, line 5
def self.call(name:, scope:)
  scope = Array(scope)
  if scope.empty?
    name
  else
    scope.each_with_index.inject('') do |str, (part, index)|
      str << (index == 0 ? part : "[#{part}]").to_s
    end + "[#{name}]"
  end
end