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
41
42
43
|
# File 'lib/webinkforms.rb', line 3
def params(method)
return if @params[method].nil? or @params[method].empty?
objects = {:params => {}, :refs => {}, :others => {}}
@params[method].keys.each do |k|
if k =~ /^#{prefix_submit}(.*)$/
name = $1
objects[:submit] = Ink::Model.from_refstr(name) || name
objects[:submit_value] = @params[method][k]
elsif k =~ /^#{prefix_set}(.*)$/
name = $1
obj = nil
if @params[method][k].is_a? Array
obj = @params[method][k].map{|i| Ink::Model.from_refstr(i) || i}
else
obj = Ink::Model.from_refstr(@params[method][k]) ||
@params[method][k]
end
objects[:params][name] = obj
elsif k =~ /^#{prefix_ref}(.*)$/
name = $1
obj = nil
if @params[method][k].is_a? Array
obj = @params[method][k].map{|i| Ink::Model.from_refstr(i) || i}
else
obj = Ink::Model.from_refstr(@params[method][k]) ||
@params[method][k]
end
ref = Ink::Model.from_refstr(name) || name
objects[:refs][ref] = obj
else
objects[:others][k] = @params[method][k]
end
end
if block_given?
yield(objects)
nil
else
objects
end
end
|