Method: Graphiti::Stats::DSL#calculation

Defined in:
lib/graphiti/stats/dsl.rb

#calculation(name) ⇒ Proc

Grab a calculation proc. Raises error if no corresponding stat has been configured.

Parameters:

  • name (String, Symbol)

    the name of the calculation, e.g. :total

Returns:

  • (Proc)

    the proc to run the calculation



64
65
66
67
# File 'lib/graphiti/stats/dsl.rb', line 64

def calculation(name)
  callable = @calculations[name] || @calculations[name.to_sym]
  callable || raise(Errors::StatNotFound.new(@name, name))
end