Skip to content

Commit

Permalink
storage: save when default is set
Browse files Browse the repository at this point in the history
  • Loading branch information
rdp committed Feb 17, 2010
1 parent 8a4f7f9 commit 5340cc4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion plugins/core/lib/core/plugin/storage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ def []=(key, value)

def set_default(key, value)
unless @storage[key]
@storage[key] = value
self[key] = value
end
value
end

def keys
Expand Down
9 changes: 6 additions & 3 deletions plugins/core/spec/core/storage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@

it "has a set default method" do
storage = Redcar::Plugin::Storage.new('test_storage_saved')
storage.set_default('a', 'b')
storage.set_default('a', 'b')
storage['a'].should == 'b'
storage = Redcar::Plugin::Storage.new('test_storage_saved')
storage['a'].should == 'b'
storage['a'] = 'c'
storage['a'].should == 'c'
end

storage = Redcar::Plugin::Storage.new('test_storage_saved')
storage['a'].should == 'c'
end

end

0 comments on commit 5340cc4

Please sign in to comment.