Updated Rake tasks and test, spec to reflect change in how Merb environments
[merb_mart.git] / app / models / role.rb
blob0f53eb5e40b770e60a81881f3f487aaf11d16a83
1 # A role is a collection of rights.
3 class Role
4   
5   include DataMapper::Persistable
6   
7   has_and_belongs_to_many :users 
8   has_and_belongs_to_many :rights, :order => 'name ASC'
10   property :name,        :string
11   property :description, :text
13   # Sets rights by list of id's passed in
14   def right_ids=(id_list)
15     self.rights.clear
16     for id in id_list
17       next if id.empty?
18       right = Right[id]
19       self.rights << right if right
20     end
21   end
23 end