Method: OpenSearch::API::Utils#__pathify

Defined in:
lib/opensearch/api/utils.rb

#__pathify(*segments) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Create a path (URL part) from arguments, ignoring nil values and empty strings.

# @example Encode special characters

__pathify(['foo', 'bar^bam']) # => 'foo/bar%5Ebam'

Examples:

Create a path from array

__pathify(['foo', '', nil, 'bar']) # => 'foo/bar'

Create a path from arguments

__pathify('foo', '', nil, 'bar') # => 'foo/bar'

API:

  • private



85
86
87
88
89
90
91
# File 'lib/opensearch/api/utils.rb', line 85

def __pathify(*segments)
  Array(segments).flatten.
    compact.
    reject { |s| s.to_s.strip.empty? }.
    join('/').
    squeeze('/')
end