OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
add documentation for PayloadRepresenter
Christophe Bliard54c65ea00ad9
diff --git a/lib/api/utilities/payload_representer.rb b/lib/api/utilities/payload_representer.rbindex f2688d2290c..c09214d2c7a 100644--- a/lib/api/utilities/payload_representer.rb+++ b/lib/api/utilities/payload_representer.rb@@ -28,6 +28,15 @@module APImodule Utilities+ # PayloadRepresenter responsibility is to parse user params input and render+ # only the writeable attributes.+ #+ # The `UpdateContract` or the `CreateContract` is used to filter out read+ # only attributes from the input parameters. Guessing is done by checking if+ # the record is a new record.+ #+ # This module is intended to be included in a dedicated PayloadRepresenter+ # class inheriting from the non-payload representer.module PayloadRepresenterdef self.included(base)base.extend(ClassMethods)@@ -46,7 +55,7 @@ module APIend# Only filter unwritable if not a lambda- unless writeable&.respond_to?(:call)+ unless writeable.respond_to?(:call)add_filter(property, UnwriteablePropertyFilter)endend@@ -70,7 +79,7 @@ module APIwriteable_attr = options[:decorator].writeable_attributesinput.reject do |link|- link.rel && !writeable_attr.include?(link.rel.to_s)+ link.rel && writeable_attr.exclude?(link.rel.to_s)endendend@@ -124,7 +133,7 @@ module APIprivatedef contract_class(represented)- return nil unless represented&.respond_to?(:new_record?)+ return nil unless represented.respond_to?(:new_record?)contract_namespace = represented.class.name.pluralizediff --git a/modules/storages/lib/api/v3/file_links/file_link_payload_representer.rb b/modules/storages/lib/api/v3/file_links/file_link_payload_representer.rbindex 198b8b5a175..246e942d1b5 100644--- a/modules/storages/lib/api/v3/file_links/file_link_payload_representer.rb+++ b/modules/storages/lib/api/v3/file_links/file_link_payload_representer.rb@@ -29,6 +29,8 @@module APImodule V3module FileLinks+ # PayloadRepresenter mixin will filter out read-only attributes from user+ # params input.class FileLinkPayloadRepresenter < FileLinkRepresenterinclude ::API::Utilities::PayloadRepresenterend