SOT: Ruby Question


#1

I have the following code. It works but it seems to me that there must
be a
clearer, more compact way. Is there a way in Ruby to pass a method name
to a
method? Something simpler than a block or lambda?

TIA,
Jeffrey

module Preload
def Preload.info_msg(msg)
Preload.common_msg(msg) {|msg| RAILS_DEFAULT_LOGGER.info msg}
end

def Preload.debug_msg(msg)
Preload.common_msg(msg, lambda{|msg| RAILS_DEFAULT_LOGGER.debug
msg})
end

def Preload.common_msg(msg, logger = nil)
puts msg
if logger
logger.call(msg)
else
yield msg
end
msg
end
end