lib/ruby_ext/declarative_cache.rb in ruby-ext-0.4.1 vs lib/ruby_ext/declarative_cache.rb in ruby-ext-0.4.2
- old
+ new
@@ -61,18 +61,21 @@
alias_method als, method
define_method method do |*args|
unless results = instance_variable_get(iv)
- results = {}
+ results = Hash.new(NotDefined)
instance_variable_set iv, results
end
+
+ result = results[args]
- unless results.include? args
- results[args] = send als, *args
+ if result.equal? NotDefined
+ result = send als, *args
+ results[args] = result
end
- results[args]
+ result
end
end
end
end
\ No newline at end of file