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
|
2014-11-27 12:30:08 +00:00
|
|
|
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
|