]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
Rework cached? for get_cached replies to prevent warnings about redefined methods
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Wed, 25 Oct 2006 22:30:38 +0000 (22:30 +0000)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Wed, 25 Oct 2006 22:30:38 +0000 (22:30 +0000)
lib/rbot/httputil.rb

index c1c8f4c107c83b6e2bedb6f966045775d375a9fc..d89fa2e920d3dc6191bc246b6389010ea6814717 100644 (file)
@@ -354,18 +354,23 @@ class HttpUtil
     if expired?(uri, readtimeout, opentimeout)
       debug "Cache expired"
       bod = get(uri, readtimeout, opentimeout, max_redir, [noexpire])
-      def bod.cached?; false; end
+      bod.instance_variable_set(:@cached,false)
     else
       k = uri.to_s
       debug "Using cache"
       @cache[k][:count] += 1
       @cache[k][:last_use] = Time.now
       bod = @cache[k][:body]
-      def bod.cached?; true; end
+      bod.instance_variable_set(:@cached,true)
     end
     unless noexpire
       remove_stale_cache
     end
+    unless bod.respond_to?(:cached?)
+      def bod.cached?
+        return @cached
+      end
+    end
     return bod
   end