module Scrivito class PublishAbility < Struct.new(:user, :workspace, :obj) def self.mget(user, workspace, obj_ids) objs = workspace.objs.find_including_deleted(obj_ids) obj_ids.map do |obj_id| PublishAbility.new(user, workspace, objs.find { |obj| obj.id == obj_id }) end end def as_json { restriction_messages: restriction_messages } end private def restriction_messages if obj user.restriction_messages_for(obj) else [] end end end end