14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/strict/interface.rb', line 14
def expose(method_name, &block)
sig = sig(&block)
parameter_list = [
*sig.parameters.map { |parameter| "#{parameter.name}:" },
"&block"
].join(", ")
argument_list = [
*sig.parameters.map { |parameter| "#{parameter.name}: #{parameter.name}" },
"&block"
].join(", ")
module_eval(<<~RUBY, __FILE__, __LINE__ + 1)
def #{method_name}(#{parameter_list}) # def method_name(one:, two:, three:, &block)
implementation.#{method_name}(#{argument_list}) # implementation.method_name(one: one, two: two, three: three, &block)
end # end
RUBY
end
|