Class: RspecApiDocs::Renderer::JSONRenderer::Name

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec_api_docs/formatter/renderer/json_renderer/name.rb

Class Method Summary collapse

Class Method Details

.call(name:, scope:) ⇒ Object


5
6
7
8
9
10
11
12
13
14
# 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