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

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

Constant Summary

Constants included from WithDAORegistry

WithDAORegistry::DEFAULT_DAO_REGISTRY_LOADER

Constants included from Inspectable

Inspectable::SPACE

Instance Attribute Summary

Attributes inherited from CommonAggregation

#name

Attributes included from WithDAORegistry

#dao_registry_loader

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 WithDAORegistry

#dao_registry, #dao_registry=, #default_dao_registry, loader_or_registry_or_default, #set_dao_registry, #set_dao_registry_and_loader, #set_dao_registry_loader, #set_default_dao_registry_loader

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



118
119
120
# File 'lib/artirix_data_models/aggregations_factory.rb', line 118

def self.sort_by_callable
  @sort_by_callable
end

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

Raises:

  • (ArgumentError)


122
123
124
125
126
# File 'lib/artirix_data_models/aggregations_factory.rb', line 122

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

  @sort_by_callable = callable || block
end

Instance Method Details

#bucketsObject



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

def buckets
  @sorted_buckets ||= sort_buckets
end

#sort_bucketsObject



114
115
116
# File 'lib/artirix_data_models/aggregations_factory.rb', line 114

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

#unordered_bucketsObject



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

alias_method :unordered_buckets, :buckets