Sha256: e574c3f298ed90d418dfb18cb9e99c591f9d8a52945f59985ccd20fca1f6d59d
Contents?: true
Size: 1021 Bytes
Versions: 1
Compression:
Stored size: 1021 Bytes
Contents
module Flyboy module AbilityHelper def define_flyboy_abilities # 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, 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 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
flyboy-1.1.0 | app/models/flyboy/ability_helper.rb |