module Ddr module Auth class PublicationAbilityDefinitions < AbilityDefinitions # An object can't be published if it's already published or not publishable # It can't be unpublished if it's already unpublished # It can't be made nonpublishable if it's already published (must be unpublished # first) or already nonpublishable def call cannot :publish, Ddr::Resource do |obj| obj.published? || !obj.publishable? end cannot :unpublish, Ddr::Resource do |obj| !obj.published? end cannot :make_nonpublishable, Ddr::Resource do |obj| obj.published? || !obj.publishable? end end end end end