diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2006-10-25 22:30:38 +0000 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2006-10-25 22:30:38 +0000 |
commit | d5c94ce03c4e0e5d8f888bef999471941048f682 (patch) | |
tree | 350e064273dc1c478dddf2aaddd8c2c1d37aede8 /lib/rbot | |
parent | 095bed99d981570f2016b4552219e5155773dab8 (diff) |
Rework cached? for get_cached replies to prevent warnings about redefined methods
Diffstat (limited to 'lib/rbot')
-rw-r--r-- | lib/rbot/httputil.rb | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/rbot/httputil.rb b/lib/rbot/httputil.rb index c1c8f4c1..d89fa2e9 100644 --- a/lib/rbot/httputil.rb +++ b/lib/rbot/httputil.rb @@ -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 |