Module: Mutant::Result::ClassMethods

Defined in:
lib/mutant/result.rb

Overview

Class level mixin

Instance Method Summary collapse

Instance Method Details

#computeResult

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Compute result tracking runtime



64
65
66
67
# File 'lib/mutant/result.rb', line 64

def compute
  start = Time.now
  new(yield.merge(runtime: Time.now - start))
end

#sum(name, collection) ⇒ undefined

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Generate a sum method from name and collection



51
52
53
54
55
56
# File 'lib/mutant/result.rb', line 51

def sum(name, collection)
  define_method(name) do
    public_send(collection).map(&name).reduce(0, :+)
  end
  memoize name
end