blob: 856f9d22d6af393c70877b7eb22611f2b9c11cb6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
module Lib
module OhmUtil
def self.check_params(model, params)
prop_names = model.attributes.collect{|p| p.to_s}
params.keys.each do |k|
key = k.to_s
if (key == "subjectid" || key == "media")
params.delete(k)
else
unless prop_names.include?(key)
key = key.from_rdf_format
unless prop_names.include?(key)
key = key+"_uri"
unless prop_names.include?(key)
key = key+"s"
unless prop_names.include?(key)
raise OpenTox::BadRequestError.new "no attribute found: '"+k.to_s+"'"
end
end
end
end
params[key.to_sym] = params.delete(k)
end
end
params
end
def self.find(model, filter_params)
params = check_params(model,filter_params)
if (params.size==0)
model.all
else
model.find(params)
end
end
end
end
|