8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/dor/utils/predicate_patch.rb', line 8
def self.short_predicate(predicate)
if match = /^(#{Predicates.predicate_mappings.keys.sort.reverse.join('|')})(.+)$/.match(predicate.to_str)
namespace = match[1]
predicate = match[2]
ns_mapping = Predicates.predicate_mappings[namespace] ||= {}
pred = ns_mapping.invert[predicate]
if pred.nil?
pred = predicate.underscore.to_sym
ns_mapping[pred] = predicate
end
pred
else
raise "Unable to parse predicate: #{predicate}"
end
end
|