summaryrefslogtreecommitdiff
path: root/rbot
diff options
context:
space:
mode:
authorTom Gilbert <tom@linuxbrit.co.uk>2005-07-26 22:49:19 +0000
committerTom Gilbert <tom@linuxbrit.co.uk>2005-07-26 22:49:19 +0000
commit1fae46c1fb122a63bd665d524f1ba231d65d1f24 (patch)
tree1ead444c7fa3d4fe48226758993d913058a8f927 /rbot
parent269578213cc727d757c8645eebc41304d01e87ce (diff)
allow failed requirements tests to fall back to defaults and continue
Diffstat (limited to 'rbot')
-rw-r--r--rbot/messagemapper.rb16
1 files changed, 13 insertions, 3 deletions
diff --git a/rbot/messagemapper.rb b/rbot/messagemapper.rb
index d03721c6..42563d23 100644
--- a/rbot/messagemapper.rb
+++ b/rbot/messagemapper.rb
@@ -102,8 +102,18 @@ module Irc
options[item.to_s.sub(/^\*/,"").intern] = value
elsif item.kind_of? Symbol
value = components.shift || @defaults[item]
- return nil, requirements_for(item) unless passes_requirements?(item, value)
- options[item] = value
+ if passes_requirements?(item, value)
+ options[item] = value
+ else
+ if @defaults.has_key?(item)
+ debug "item #{item} doesn't pass reqs but has a default of #{@defaults[item]}"
+ options[item] = @defaults[item].clone
+ # push the test-failed component back on the stack
+ components.unshift value
+ else
+ return nil, requirements_for(item)
+ end
+ end
else
return nil, "No value available for component #{item.inspect}" if components.empty?
component = components.shift
@@ -123,7 +133,7 @@ module Irc
def inspect
when_str = @requirements.empty? ? "" : " when #{@requirements.inspect}"
default_str = @defaults.empty? ? "" : " || #{@defaults.inspect}"
- "<#{self.class.to_s} #{@items.collect{|c| c.kind_of?(String) ? c : c.inspect}.join('/').inspect}#{default_str}#{when_str}>"
+ "<#{self.class.to_s} #{@items.collect{|c| c.kind_of?(String) ? c : c.inspect}.join(' ').inspect}#{default_str}#{when_str}>"
end
# Verify that the given value passes this route's requirements