Sha256: 87fc93de4319718f4de72ed2581ae3d4977b4df7ed134239384fcef50c26cfa7
Contents?: true
Size: 793 Bytes
Versions: 9
Compression:
Stored size: 793 Bytes
Contents
module Thredded class PostUserPermissions attr_reader :post, :user, :user_details, :messageboard, :topic def initialize(post, user, user_details) @post = post @topic = post.topic @messageboard = post.messageboard @user = user @user_details = user_details || UserDetail.new end def editable? created_post? || messageboard.member_is_a?(user, 'admin') end def manageable? created_post? end def creatable? thread_is_not_locked? && can_create_topic? end private def created_post? user.id == post.user_id end def thread_is_not_locked? !@topic.locked? end def can_create_topic? TopicUserPermissions.new(@topic, @user, @user_details).creatable? end end end
Version data entries
9 entries across 9 versions & 1 rubygems