Cache: vars renamed

This commit is contained in:
Denis Knauf 2010-03-29 23:12:43 +02:00
parent fb987eb461
commit 7a26a9dfad

View file

@ -10,16 +10,16 @@ class LogAn::Cache
end end
def flush! def flush!
@data.each {|k,v| @obj[k] = v } @data.each {|k,v| @source[k] = v }
@data = {} @data = {}
end end
def dget k def dget k
@data[k] ||= @obj[k] @data[k] ||= @source[k]
end end
def oget k def oget k
@data[k] || @obj[k] @data[k] || @source[k]
end end
def dset k, v def dset k, v
@ -27,7 +27,7 @@ class LogAn::Cache
end end
def oset k, v def oset k, v
@obj[k] = v @source[k] = v
end end
def type= type def type= type
@ -49,7 +49,7 @@ class LogAn::Cache
#def each &e #def each &e
#return Enumerator.new self, :each unless e #return Enumerator.new self, :each unless e
#flush! #flush!
#@obj.each &e #@source.each &e
#self #self
#end #end
end end
@ -58,18 +58,18 @@ class LogAn::AutoValueConvertHash
include Enumerable include Enumerable
attr_reader :decode, :encode attr_reader :decode, :encode
def initialize obj, encode = nil, each = nil, &decode def initialize source, encode = nil, each = nil, &decode
@object, @encoder = obj, decode.nil? ? encode || Marshal.method( :dump) : nil, @source, @encoder = source, decode.nil? ? encode || Marshal.method( :dump) : nil,
@each = each || obj.method( :each) rescue NameError @each = each || source.method( :each) rescue NameError
@decode = decode || Marshal.method( :restore) @decode = decode || Marshal.method( :restore)
end end
def [] k def [] k
@decode.call @object[k] @decode.call @source[k]
end end
def []= k, v def []= k, v
@object[k] = @encode.call v @source[k] = @encode.call v
end end
def each *paras def each *paras