3
4
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
37
|
# File 'app/models/flyboy/ability_helper.rb', line 3
def define_flyboy_abilities
can [:list, :create, :read, :update, :delete, :open, :close], Flyboy::Goal
can [:list, :create, :read, :update, :delete, :complete, :snooze], Flyboy::Task
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, Flyboy::Task do |task|
task.taskable.present? && cannot?(:show, task.taskable)
end
cannot [:create, :update, :delete], Flyboy::Task do |task|
task.taskable.is_a?(Flyboy::Goal) && task.taskable.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
|