Method: PgGraph::Reflector#that

Defined in:
lib/pg_graph/reflector.rb

#that(uid, unique, multi = false, table: nil) ⇒ Object

Find ‘that’ field name for the given UID by searching through reflections for a match. The name is pluralized if the matcher returns true or if the matcher returns nil and unique is false. The :table option can be used to override the table name in ‘$$’ rules. This is used in N:M and M:M relations. Returns false if the :that property is set to false in the reflections file. Returns nil if no match was found or if a matching reflection has #continue equal to false



160
161
162
163
164
165
166
167
168
169
# File 'lib/pg_graph/reflector.rb', line 160

def that(uid, unique, multi = false, table: nil)
  constrain uid, String
  if (name, pluralize = do_match(uid, :that, multi, table: table))
    if pluralize.nil? && !unique || pluralize
      PgGraph.inflector.pluralize(name)
    else
      name
    end
  end
end