Module: Risky::ListKeys::ClassMethods
- Defined in:
- lib/risky/list_keys.rb
Instance Method Summary collapse
-
#all(opts = {:reload => true}) ⇒ Object
Returns all model instances from the bucket.
-
#count ⇒ Object
Counts the number of values in the bucket via key streaming.
-
#delete_all ⇒ Object
Deletes all model instances from the bucket.
-
#each ⇒ Object
Iterate over all items using key streaming.
-
#keys(*a) ⇒ Object
Iterate over all keys.
Instance Method Details
#all(opts = {:reload => true}) ⇒ Object
Returns all model instances from the bucket
9 10 11 |
# File 'lib/risky/list_keys.rb', line 9 def all(opts = {:reload => true}) find_all_by_key(bucket.keys(opts)) end |
#count ⇒ Object
Counts the number of values in the bucket via key streaming.
14 15 16 17 18 19 20 |
# File 'lib/risky/list_keys.rb', line 14 def count count = 0 bucket.keys do |keys| count += keys.length end count end |
#delete_all ⇒ Object
Deletes all model instances from the bucket.
23 24 25 26 27 |
# File 'lib/risky/list_keys.rb', line 23 def delete_all each do |item| item.delete end end |
#each ⇒ Object
Iterate over all items using key streaming.
48 49 50 51 52 53 54 55 56 |
# 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) ⇒ Object
Iterate over all keys.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# 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 |