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
44
45
46
|
# File 'lib/action_handler/args_maker.rb', line 11
def make_args(method, supplier, context: nil)
supplier_args = [context].compact
values = []
keywords = {}
method.parameters.each do |kind, name|
unless supplier.respond_to?(name)
raise ActionHandler::ActionArgumentError.new(
method,
"parameter #{name} is not defined in #{supplier}",
)
end
case kind
when :req
values << supplier.send(name, *supplier_args)
when :keyreq
keywords[name] = supplier.send(name, *supplier_args)
when :opt, :key
raise ActionHandler::ActionArgumentError.new(method, " Do not use optional arguments.\n ActionHandler always injects arguments even if the value is nil,\n so the optional values never be used.\n ERR\n when :rest, :keyrest\n raise ActionHandler::ActionArgumentError.new(\n method,\n 'rest arguments cannot be used',\n )\n end\n end\n\n values << keywords unless keywords.empty?\n values\nend\n")
|