asciinema.org/app/policies/asciicast_policy.rb
2015-05-10 16:40:39 +00:00

38 lines
640 B
Ruby

class AsciicastPolicy < ApplicationPolicy
class Scope < Struct.new(:user, :scope)
def resolve
scope
end
end
def permitted_attributes
if user.admin? || record.owner?(user)
attrs = [:title, :description, :theme_name, :snapshot_at]
attrs << :featured if change_featured?
attrs << :private if change_visibility?
attrs
else
[]
end
end
def update?
user.admin? || record.owner?(user)
end
def destroy?
user.admin? || record.owner?(user)
end
def change_featured?
user.admin?
end
def change_visibility?
user.admin? || record.owner?(user)
end
end