lib/flapjack/data/entity.rb in flapjack-0.8.0 vs lib/flapjack/data/entity.rb in flapjack-0.8.1
- old
+ new
@@ -15,9 +15,10 @@
TAG_PREFIX = 'entity_tag'
def self.all(options = {})
raise "Redis connection not set" unless redis = options[:redis]
keys = redis.keys("entity_id:*")
+ return [] unless keys.any?
ids = redis.mget(keys)
keys.collect {|k|
k =~ /^entity_id:(.+)$/; entity_name = $1
self.new(:name => entity_name, :id => ids.shift, :redis => redis)
}.sort_by(&:name)