lib/scrivito/publish_ability.rb in scrivito_sdk-1.7.0 vs lib/scrivito/publish_ability.rb in scrivito_sdk-1.8.0.rc1
- old
+ new
@@ -1,14 +1,25 @@
module Scrivito
- class PublishAbility < Struct.new(:scrivito_user, :workspace, :obj_id)
+ 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}
+ { restriction_messages: restriction_messages }
end
private
def restriction_messages
- obj = workspace.objs.find_including_deleted(obj_id)
- scrivito_user.restriction_messages_for(obj)
+ if obj
+ user.restriction_messages_for(obj)
+ else
+ []
+ end
end
end
end