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
44
45
46
47
48
49
50
51
52
|
# File 'lib/base.rb', line 17
def do_request(hash, wx_event = nil)
params, options = hash.has_key?(:link) ? [hash[:link], hash] : [hash, {}]
new_params = params.dup
forms = options[:forms]
forms = [forms] unless forms.is_a?(Array)
forms.compact.each do |form|
form_name, window = case form
when :self
[:self, self]
when ::Wx::Window
raise InvalidForm, "Window #{form} has no name!" unless name = form.get_name
[name, form]
when String
raise InvalidForm, "No window named #{form}" unless win = ::Wx::Window.find_window_by_name(form, self)
[form, win]
else
raise InvalidForm, "Unhandled param, passed form: #{form.inspect}"
end
form_param = {}
window.get_children.each {|child| next unless child.get_name =~ /^[\da-z_]+$/ ;form_param[child.get_name] = child.value} new_params[form_name] = form_param
end
continue = (late_proc = options[:late]) ? late_proc.call(new_params, wx_event) : true
request = Request.new(new_params)
request.local_assigns = options[:locals]
Base.handle_request(request) if continue
end
|