Method: JSONSchemer::Schema#absolute_keyword_location

Defined in:
lib/json_schemer/schema.rb

#absolute_keyword_locationObject



272
273
274
275
276
277
278
279
280
281
282
283
# File 'lib/json_schemer/schema.rb', line 272

def absolute_keyword_location
  # using `equal?` because `URI::Generic#==` is slow
  @absolute_keyword_location ||= if !parent || (!parent.schema.base_uri.equal?(base_uri) && (base_uri.fragment.nil? || base_uri.fragment.empty?))
    absolute_keyword_location_uri = base_uri.dup
    absolute_keyword_location_uri.fragment = ''
    absolute_keyword_location_uri.to_s
  elsif keyword
    "#{parent.absolute_keyword_location}/#{fragment_encode(escaped_keyword)}"
  else
    parent.absolute_keyword_location
  end
end