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:
soh_cah_toa
2013-06-05 18:20:48 -04:00
parent 6c61b39d81
commit 89a5d6fdbb
2 changed files with 7 additions and 7 deletions

View File

@@ -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

View File

@@ -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