OSDN Git Service

fix:error dlg
[pettanr/pettanr.git] / lib / peta / owner.rb
1 module Peta
2   class Owner < Item
3     self.abstract_class = true
4     # ClassMethods
5     
6     def self.edit owner_id, operators
7       owner = self.find owner_id
8       raise ActiveRecord::Forbidden unless owner.own?(operators)
9       owner
10     end
11     
12     #InstanceMethods
13     
14     def overwrite operators
15       self.user_id = operators.user.id
16     end
17     
18     def own? operators
19       return false unless operators.user
20       self.user_id == operators.user.id
21     end
22     
23   end
24 end
25