Class: CanDo::Role
- Inherits:
-
Object
- Object
- CanDo::Role
- Defined in:
- lib/models/role.rb
Defined Under Namespace
Classes: UndefinedRole
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.define_role(name, capabilities) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/models/role.rb', line 16 def self.define_role(name, capabilities) role = Role.find_or_create(:id => name) role.remove_all_capabilities capabilities.each do |capability| role.add_capability( Capability.find_or_create(:id => capability.to_s) ) end role end |
Instance Method Details
#before_destroy ⇒ Object
10 11 12 13 14 |
# File 'lib/models/role.rb', line 10 def before_destroy self.remove_all_capabilities self.remove_all_users Capability.cleanup end |
#to_s ⇒ Object
26 27 28 |
# File 'lib/models/role.rb', line 26 def to_s "#{id}\t#{capabilities.map(&:id).join(",")}" end |