Method: Openapi3Parser::CautiousDig#call

Defined in:
lib/openapi3_parser/cautious_dig.rb

#call(collection, *segments) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/openapi3_parser/cautious_dig.rb', line 11

def call(collection, *segments)
  segments.inject(collection) do |next_depth, segment|
    break unless next_depth

    if next_depth.respond_to?(:keys)
      hash_like(next_depth, segment)
    elsif next_depth.respond_to?(:[])
      array_like(next_depth, segment)
    end
  end
end