module Mutest::Result::ClassMethods
Class level mixin
Public Instance Methods
sum(name, collection)
click to toggle source
Generate a sum method from name and collection
@param [Symbol] name
the attribute name on collection item and method name to use
@param [Symbol] collection
the attribute name used to receive collection
@return [undefined]
# File lib/mutest/result.rb, line 32 def sum(name, collection) define_method(name) do public_send(collection).map(&name).reduce(0, :+) end memoize(name) end