Method: NoSE::KeyPath#path_for_field

Defined in:
lib/nose/statements.rb

#path_for_field(field) ⇒ Array<String>

Get the named path to reach this field through the list of keys

Returns:



228
229
230
231
232
233
234
# File 'lib/nose/statements.rb', line 228

def path_for_field(field)
  return [field.name] if @keys.first.parent == field.parent

  @keys.each_cons(2).take_while do |prev_key, _|
    prev_key.entity != field.parent
  end.map(&:last).map(&:name) << field.name
end