Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add Risky.keys

  • Loading branch information...
commit d5e063c2bc8c5d7098fe8a4c95599f3eef3aa902 1 parent 2819b80
Kyle Kingsbury authored
Showing with 25 additions and 0 deletions.
  1. +18 −0 lib/risky.rb
  2. +7 −0 spec/enumerable.rb
View
18 lib/risky.rb
@@ -132,6 +132,24 @@ def self.from_riak_object(riak_object)
def self.get_or_new(*args)
self[*args] or new(args.first)
end
+
+ # Iterate over all keys.
+ def self.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
# Establishes methods for manipulating a single link with a given tag.
def self.link(tag)
View
7 spec/enumerable.rb
@@ -27,6 +27,13 @@ class Enum < Risky
Enum.count.should == 3
end
+ should 'list keys' do
+ Enum.keys.should.be.kind_of? Array
+ Enum.keys do |key|
+ key.should.be.kind_of? String
+ end
+ end
+
should 'each' do
seen = []
Enum.each do |obj|
Please sign in to comment.
Something went wrong with that request. Please try again.