20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/rango/mixins/action_args.rb', line 20
def invoke_action(action)
view = self.method(action)
parameters = view.parameters.map! { |type, name| [type, name.to_s] }
names = parameters.map { |type, name| name }
required = parameters.map { |type, name| name if type.eql?(:req) }.compact
unless ( = required - self.params.keys).empty?
raise ArgumentError, "Following keys aren't available in params: #{.inspect}\nAvailable keys: #{self.params.keys.inspect}"
end
args = Array.new
parameters.each do |type, name|
args.push(self.params[name]) if type.eql?(:req) || (type.eql?(:opt) && !self.params[name].nil?) end
puts "Rendering #{self.class}##{action} with #{args.map(&:inspect).join(", ")}"
self.response.body = self.send(action, *args)
end
|