Class: MoulinRouge::CanCan::Ability
- Inherits:
-
Object
- Object
- MoulinRouge::CanCan::Ability
- Includes:
- CanCan::Ability
- Defined in:
- lib/moulin_rouge/cancan/ability.rb
Instance Method Summary collapse
-
#initialize(model) ⇒ Ability
constructor
Define all permissions collect by MoulinRouge.
Constructor Details
#initialize(model) ⇒ Ability
Define all permissions collect by MoulinRouge
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/moulin_rouge/cancan/ability.rb', line 8 def initialize(model) model = MoulinRouge.configuration.model.new if model.nil? and not MoulinRouge.configuration.model.nil? # Reload all permissions if cache is disabled MoulinRouge.reload! unless MoulinRouge.configuration.cache # Set all abilities in main MoulinRouge::Authorization.main.abilities.each do |ability| ability.send_to(self, model) end # Set all abilities by role MoulinRouge::Authorization.abilities.each do |role, ability| ability.abilities.each do |cancan_ability| cancan_ability.send_to(self, model) end if model.send(MoulinRouge.configuration.test_method, role) end end |