For learning purposes, I'm exploring if I can convert these three method calls:
Foo::Bar.logger.debug(a)
Foo::Bar.logger.debug(b)
Foo::Bar.logger.debug(c)
into a single-line statement using the shorthand proc &method approach:
[a, b, c].each(&method(:'Foo::Bar.logger.debug'))
.debug does not respond to .to_proc so naturally:
NameError: undefined method `Foo::Bar.logger.debug' for class `#<Class:Foo>'
This does work; however, but isn't as succinct as the former:
logger = Proc.new { |x| Foo::Bar.logger.debug(x) }
[a, b, c].each(&logger)
Is it possible for the former approach to work?