Module: Groupdate::Relation

Extended by:
ActiveSupport::Concern
Defined in:
lib/groupdate/relation.rb

Instance Method Summary collapse

Instance Method Details

#calculate(*args, &block) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/groupdate/relation.rb', line 11

def calculate(*args, &block)
  # prevent calculate from being called twice
  return super if has_include?(args[1])

  default_value = [:count, :sum].include?(args[0]) ? 0 : nil
  Groupdate.process_result(self, super, default_value: default_value)
end