Update connect/disconnect action states.
[kaya.git] / lib / board / item_bag.rb
blobc78bd1344b65b6afac8e7b33ed1189dff0aa9e6a
1 # Copyright (c) 2009 Paolo Capriotti <p.capriotti@gmail.com>
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 require 'item'
10 module ItemBag
11   def add_item(key, opts)
12     remove_item key
13     item = create_item({:name => key}.merge(opts))
14     items[key] = item
15   end
16   
17   def remove_item(key, *args)
18     if items[key]
19       destroy_item items[key] unless args.include? :keep
20       removed = items[key]
21       items.delete(key)
22       removed
23     end
24   end
25   
26   def move_item(src, dst)
27     remove_item dst
28     items[dst] = items[src]
29     items.delete(src)
30     items[dst]
31   end
32 end