5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/bulletmark_repairer/application_associations.rb', line 5
def key(target_klass_name, base_klass_name, candidates)
key = target_klass_name.underscore
matched_candidates = candidates - (candidates - @associations[base_klass_name][:associations])
if key.pluralize.to_sym.in?(candidates)
key.pluralize.to_sym
elsif key.singularize.to_sym.in?(candidates)
key.singularize.to_sym
else
index = matched_candidates.index do |matched_candidate|
key.pluralize.to_sym.in?(@associations[base_klass_name][:aliases][matched_candidate]) ||
key.singularize.to_sym.in?(@associations[base_klass_name][:aliases][matched_candidate])
end
matched_candidates[index] if index
end
end
|