Class: Flyboy::Ability
- Inherits:
-
Object
- Object
- Flyboy::Ability
- Includes:
- CanCan::Ability
- Defined in:
- app/models/flyboy/ability.rb
Instance Method Summary collapse
-
#initialize(user = nil) ⇒ Ability
constructor
A new instance of Ability.
Constructor Details
#initialize(user = nil) ⇒ Ability
Returns a new instance of Ability.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/models/flyboy/ability.rb', line 5 def initialize(user = nil) # Allowed actions (all by default) can [:list, :create, :read, :update, :delete, :open, :close], Flyboy::Goal can [:list, :create, :read, :update, :delete, :complete, :snooze], Flyboy::Task # Restricted actions cannot [:update, :delete], Flyboy::Goal do |goal| goal.closed? end cannot :close, Flyboy::Goal do |goal| not goal.may_close? end cannot :open, Flyboy::Goal do |goal| not goal.may_open? end cannot [:create, :update, :delete], Flyboy::Task do |task| task.goal.closed? end cannot :complete, Flyboy::Task do |task| task.done? end cannot :snooze, Flyboy::Task do |task| task.done? || task.reminder >= Date.today end end |