lib/mutest/result.rb
# 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]
Generate a sum method from name and collection
Generate a sum method from name and collection
def sum(name, collection)
        define_method(name) do
          public_send(collection).map(&name).reduce(0, :+)
        end
        memoize(name)
      end
def sum ( name , collection ) define_method ( name ) do public_send ( collection ) . map ( & name ) . reduce ( 0 , :+ ) end memoize ( name ) end
Generate a sum method from name and collection
Generate a sum method from name and collection
None
undefined
name
collection
collection the attribute name used to receive collection
collection the attribute name used to receive collection