module Risky::ListKeys::ClassMethods

Public Instance Methods

all(opts = {:reload => true}) click to toggle source

Returns all model instances from the bucket

# File lib/risky/list_keys.rb, line 9
def all(opts = {:reload => true})
  find_all_by_key(bucket.keys(opts))
end
count() click to toggle source

Counts the number of values in the bucket via key streaming.

# File lib/risky/list_keys.rb, line 14
def count
  count = 0
  bucket.keys do |keys|
    count += keys.length
  end
  count
end
delete_all() click to toggle source

Deletes all model instances from the bucket.

# File lib/risky/list_keys.rb, line 23
def delete_all
  each do |item|
    item.delete
  end
end
each() { |x| ... } click to toggle source

Iterate over all items using key streaming.

# File lib/risky/list_keys.rb, line 48
def each
  bucket.keys do |keys|
    keys.each do |key|
      if x = self[key]
        yield x
      end
    end
  end
end
keys(*a) { |key| ... } click to toggle source

Iterate over all keys.

# File lib/risky/list_keys.rb, line 30
def keys(*a)
  if block_given?
    bucket.keys(*a) do |keys|
      # This API is currently inconsistent from protobuffs to http
      if keys.kind_of? Array
        keys.each do |key|
          yield key
        end
      else
        yield keys
      end
    end
  else
    bucket.keys(*a)
  end
end