asciinema.org/app/policies/asciicast_policy.rb

45 lines
670 B
Ruby
Raw Normal View History

2014-07-05 12:59:42 +00:00
class AsciicastPolicy < ApplicationPolicy
class Scope < Struct.new(:user, :scope)
def resolve
scope
end
end
def permitted_attributes
if user.admin? || record.user == user
attrs = [:title, :description, :theme_name, :snapshot_at]
2014-07-05 12:59:42 +00:00
attrs << :featured if user.admin?
attrs
else
[]
end
end
def update?
return false unless user
user.admin? || record.user == user
end
def destroy?
return false unless user
user.admin? || record.user == user
end
def feature?
return false unless user
user.admin?
end
def unfeature?
return false unless user
user.admin?
end
end