class Attr::Gather::Aggregators::Base
@abstract Subclass and override {#call} to implement
a custom Aggregator class.
@!attribute [r] filter
@return [Attr::Gather::Filters::Base] filter for the output data
Constants
- NOOP_FILTER
Attributes
filter[RW]
Public Class Methods
new(**opts)
click to toggle source
# File lib/attr/gather/aggregators/base.rb, line 18 def initialize(**opts) @filter = opts.delete(:filter) || NOOP_FILTER end
Public Instance Methods
call(_original_input, _results_array)
click to toggle source
# File lib/attr/gather/aggregators/base.rb, line 26 def call(_original_input, _results_array) raise NotImplementedError end
with(**opts)
click to toggle source
# File lib/attr/gather/aggregators/base.rb, line 22 def with(**opts) self.class.new(filter: @filter, **opts) end
Private Instance Methods
unwrap_result(res)
click to toggle source
# File lib/attr/gather/aggregators/base.rb, line 32 def unwrap_result(res) return res if filter.nil? filter.call(res).value end