Module: TestPlus::Support
Instance Method Summary collapse
-
#reduce_with(list, reduction) ⇒ Object
Module Methods =======================================================.
Instance Method Details
#reduce_with(list, reduction) ⇒ Object
Module Methods =======================================================
4 5 6 7 8 9 10 11 12 13 14 |
# 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 |