Modified #remove_rule to return a boolean value.
This is will soon allow the DELETE handler to indicate success or failure.
This commit is contained in:
@@ -79,6 +79,9 @@ module Dns
|
||||
# Removes the given DNS rule. Any future queries for it will be passed through.
|
||||
#
|
||||
# @param id [Integer] id returned from {#add_rule}
|
||||
#
|
||||
# @return [Boolean] true on success, false on failure
|
||||
#
|
||||
# @see #add_rule
|
||||
def remove_rule(id)
|
||||
@lock.synchronize do
|
||||
|
||||
@@ -44,7 +44,6 @@ module RubyDNS
|
||||
|
||||
class Rule
|
||||
|
||||
# XXX Can this be removed?
|
||||
attr_accessor :id
|
||||
|
||||
# Now uses an 'id' parameter to uniquely identify rules
|
||||
@@ -109,15 +108,13 @@ module RubyDNS
|
||||
id
|
||||
end
|
||||
|
||||
# New method that removes a rule given its id
|
||||
# New method that removes a rule given its id and returns boolean result
|
||||
def remove_rule(id)
|
||||
@rules.delete_if { |rule| rule.id == id }
|
||||
|
||||
begin
|
||||
BeEF::Core::Models::Dns::Rule.get!(id).destroy
|
||||
rescue DataMapper::ObjectNotFoundError => e
|
||||
@logger.error(e.message)
|
||||
end
|
||||
rule = BeEF::Core::Models::Dns::Rule.get(id)
|
||||
|
||||
rule != nil ? rule.destroy : false
|
||||
end
|
||||
|
||||
# New method that loads all rules from the database at server startup
|
||||
|
||||
Reference in New Issue
Block a user