Module: Enumerable
- Defined in:
- lib/each-with-logging.rb
Instance Method Summary collapse
Instance Method Details
#each_with_logging(logger = nil) ⇒ Object
2 3 4 5 6 7 8 9 |
# File 'lib/each-with-logging.rb', line 2 def each_with_logging(logger = nil) len = self.length self.each_with_index{|value, index| = "#{caller[-2]} #{index+1} / #{len}" logger.respond_to?(:debug) ? logger.debug() : warn() yield value } end |