class Trample::Aggregation

Attributes

bucket_sort[RW]

Public Instance Methods

buckets() click to toggle source
Calls superclass method
# File lib/trample/aggregation.rb, line 66
def buckets
  ordered = super
  ordered.sort!(&bucket_sort)
  ordered
end
find_or_initialize_bucket(key) click to toggle source
# File lib/trample/aggregation.rb, line 76
def find_or_initialize_bucket(key)
  bucket = buckets.find { |b| b['key'].downcase == key.downcase }
  if bucket.nil?
    bucket = Bucket.new(key: key)
    self.buckets << bucket
  end
  bucket
end
force(key, opts = {}) click to toggle source
# File lib/trample/aggregation.rb, line 72
def force(key, opts = {})
  self.buckets << opts.merge(key: key)
end
selections() click to toggle source
# File lib/trample/aggregation.rb, line 38
def selections
  buckets.select(&:selected?).map(&:key)
end
selections?() click to toggle source
# File lib/trample/aggregation.rb, line 34
def selections?
  !selections.empty?
end
to_query() click to toggle source
# File lib/trample/aggregation.rb, line 30
def to_query
  {name => selections}
end