Represents a single rule in the server.
Invoke the rule, if it matches the incoming request, it is evaluated and returns `true`, otherwise returns `false`.
# File lib/rubydns/server.rb, line 155 def call(server, name, resource_class, *args) unless match(name, resource_class) server.logger.debug "Resource class #{resource_class} failed to match #{@pattern[1].inspect}!" return false end # Does this rule match against the supplied name? case @pattern[0] when Regexp match_data = @pattern[0].match(name) if match_data server.logger.debug "Regexp pattern matched with #{match_data.inspect}." @callback[*args, match_data] return true end when String if @pattern[0] == name server.logger.debug "String pattern matched." @callback[*args] return true end else if (@pattern[0].call(name, resource_class) rescue false) server.logger.debug "Callable pattern matched." @callback[*args] return true end end server.logger.debug "No pattern matched." # We failed to match the pattern. return false end
Returns true if the name and resource_class are sufficient:
# File lib/rubydns/server.rb, line 142 def match(name, resource_class) # If the pattern doesn't specify any resource classes, we implicitly pass this test: return true if @pattern.size < 2 # Otherwise, we try to match against some specific resource classes: if Class === @pattern[1] @pattern[1] == resource_class else @pattern[1].include?(resource_class) rescue false end end
Generated with the Darkfish Rdoc Generator 2.