Class: ArtirixDataModels::AggregationsFactory::SortedBucketsAggregationClassFactory::SortedBucketAggregationBase

Inherits:
ArtirixDataModels::Aggregation show all
Defined in:
lib/artirix_data_models/aggregations_factory.rb

Constant Summary

Constants included from Inspectable

Inspectable::SPACE

Instance Attribute Summary

Attributes inherited from CommonAggregation

#name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ArtirixDataModels::Aggregation

#calculate_filtered, #data_hash, #filtered_buckets, #filtered_first_buckets, #initialize, #non_empty_buckets, #unfiltered_buckets

Methods inherited from CommonAggregation

from_json, #initialize, #pretty_name

Methods included from Inspectable

#data_hash_for_inspect, #inspect, #inspect_with_tab

Constructor Details

This class inherits a constructor from ArtirixDataModels::Aggregation

Class Method Details

.sort_by_callableObject



111
112
113
# File 'lib/artirix_data_models/aggregations_factory.rb', line 111

def self.sort_by_callable
  @sort_by_callable
end

.sort_by_callable=(callable = nil, &block) ⇒ Object

Raises:

  • (ArgumentError)


115
116
117
118
119
# File 'lib/artirix_data_models/aggregations_factory.rb', line 115

def self.sort_by_callable=(callable = nil, &block)
  raise ArgumentError unless callable || block

  @sort_by_callable = callable || block
end

Instance Method Details

#bucketsObject



103
104
105
# File 'lib/artirix_data_models/aggregations_factory.rb', line 103

def buckets
  @sorted_buckets ||= sort_buckets
end

#sort_bucketsObject



107
108
109
# File 'lib/artirix_data_models/aggregations_factory.rb', line 107

def sort_buckets
  unordered_buckets.sort_by { |bucket| self.class.sort_by_callable.call(bucket) }
end

#unordered_bucketsObject



101
# File 'lib/artirix_data_models/aggregations_factory.rb', line 101

alias_method :unordered_buckets, :buckets