module Scrivito class ObjUiConfig < Struct.new(:obj) def self.mget(workspace, obj_ids) objs = workspace.objs.find_including_deleted(obj_ids) obj_ids.map do |obj_id| ObjUiConfig.new(objs.find { |obj| obj.id == obj_id }) end end def as_json return {} unless obj { description_for_editor: obj.description_for_editor, info_for_content_browser: obj.try(:info_for_content_browser), description_for_widgets: description_for_widgets, } end private def description_for_widgets obj.widgets.each_with_object({}) do |widget, h| h[widget.id] = widget.description_for_editor end end end end