module TestPlus::Support

Public Instance Methods

reduce_with(list, reduction) click to toggle source

Module Methods =======================================================

# File lib/test_plus/support.rb, line 4
def reduce_with(list, reduction)
  case (reduction)
  when Symbol
    reduction_method = reduction
    reduction = lambda do |o|
      o.respond_to?(reduction_method) ? o.send(reduction_method) : o
    end
  end

  list.to_a.flatten.map(&reduction)
end