2017-02-13 13:58:58 -05:00
|
|
|
# frozen_string_literal: true
|
2018-02-24 01:45:50 -05:00
|
|
|
|
2018-02-24 02:41:47 -05:00
|
|
|
module Arel # :nodoc: all
|
2010-09-14 18:20:24 -04:00
|
|
|
module Expressions
|
2018-02-24 01:45:50 -05:00
|
|
|
def count(distinct = false)
|
2010-09-14 18:20:24 -04:00
|
|
|
Nodes::Count.new [self], distinct
|
|
|
|
end
|
|
|
|
|
2014-07-31 08:49:57 -04:00
|
|
|
def sum
|
2014-10-31 10:40:28 -04:00
|
|
|
Nodes::Sum.new [self]
|
2010-09-14 18:20:24 -04:00
|
|
|
end
|
|
|
|
|
2014-07-31 08:49:57 -04:00
|
|
|
def maximum
|
2014-10-31 10:40:28 -04:00
|
|
|
Nodes::Max.new [self]
|
2010-09-14 18:20:24 -04:00
|
|
|
end
|
|
|
|
|
2014-07-31 08:49:57 -04:00
|
|
|
def minimum
|
2014-10-31 10:40:28 -04:00
|
|
|
Nodes::Min.new [self]
|
2010-09-14 18:20:24 -04:00
|
|
|
end
|
|
|
|
|
2014-07-31 08:49:57 -04:00
|
|
|
def average
|
2014-10-31 10:40:28 -04:00
|
|
|
Nodes::Avg.new [self]
|
2010-09-14 18:20:24 -04:00
|
|
|
end
|
2012-02-23 08:06:05 -05:00
|
|
|
|
2018-02-24 01:45:50 -05:00
|
|
|
def extract(field)
|
2012-02-23 08:06:05 -05:00
|
|
|
Nodes::Extract.new [self], field
|
|
|
|
end
|
2010-09-14 18:20:24 -04:00
|
|
|
end
|
|
|
|
end
|