Sha256: ec740dce05d79553e9a54fe66ecd34dadb476485730f5a1b73daf5733d953fc1
Contents?: true
Size: 1.27 KB
Versions: 1
Compression:
Stored size: 1.27 KB
Contents
module Storytime class PagePolicy attr_reader :user, :page class Scope < Struct.new(:user, :scope) def resolve action = Storytime::Action.find_by(guid: "d8a1b1") if user.role.allowed_actions.include?(action) scope.all else scope.where(user_id: user.id) end end end def initialize(user, page) @user = user @page = page end def index? !@user.nil? end def create? @page.user == @user end def new? create? end def update? manage? end def edit? manage? end def destroy? manage? end def manage? if @user == @page.user true else action = Storytime::Action.find_by(guid: "d8a1b1") @user.role.allowed_actions.include?(action) end end def publish? action = if @user == @page.user Storytime::Action.find_by(guid: "5030ed") else Storytime::Action.find_by(guid: "d8a1b1") end @user.role.allowed_actions.include?(action) end def permitted_attributes if publish? [:title, :draft_content, :draft_version_id, :published] else [:title, :draft_content, :draft_version_id] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
storytime-0.0.1 | app/policies/storytime/page_policy.rb |