Skip to content

Commit

Permalink
Destroying false values (thanks to @Pavling), fixes ledermann#10
Browse files Browse the repository at this point in the history
  • Loading branch information
ledermann committed Aug 29, 2011
1 parent ba811fc commit 36293da
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/settings.rb
Expand Up @@ -31,10 +31,10 @@ def self.method_missing(method, *args)
#destroy the specified settings record
def self.destroy(var_name)
var_name = var_name.to_s
if self[var_name]
begin
target(var_name).destroy
true
else
rescue NoMethodError
raise SettingNotFound, "Setting variable \"#{var_name}\" not found"
end
end
Expand Down
12 changes: 12 additions & 0 deletions test/settings_test.rb
Expand Up @@ -135,6 +135,18 @@ def test_merge
def test_destroy
Settings.destroy :test
assert_equal nil, Settings.test

assert_raise(Settings::SettingNotFound) do
Settings.destroy :unknown
end
end

def test_false
Settings.test3 = false
assert_setting(false, 'test3')

Settings.destroy :test3
assert_setting(nil, 'test3')
end

private
Expand Down

0 comments on commit 36293da

Please sign in to comment.