From 3fa3ac495d0243f35757ba745e51bbf883f5e3f3 Mon Sep 17 00:00:00 2001 From: Denis Knauf Date: Tue, 30 Mar 2010 11:43:59 +0200 Subject: [PATCH] Cache#each -> AVCH#each_keys --- lib/logan/cache.rb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/logan/cache.rb b/lib/logan/cache.rb index 31dfd8d..4ab7e98 100644 --- a/lib/logan/cache.rb +++ b/lib/logan/cache.rb @@ -46,9 +46,10 @@ class LogAn::Cache end include Enumerable - def each + def each *paras return Enumerator.new self, :each unless block_given? - (@source.keys + @data.keys).each do |key| + flush! if @type&2 == 2 + @source.each_keys( *paras) do |key| yield key, self[key] end self @@ -74,8 +75,16 @@ class LogAn::AutoValueConvertHash end def each *paras + return Enumerator.new self, :each unless block_given? @each.call *paras do |k, v| yield k, @decode.call( v) end end + + def each_keys *paras + return Enumerator.new self, :each_keys unless block_given? + @each.call *paras do |k, v| + yield k + end + end end