use same names and magic in payload as everywhere

as introduced in Single
pull/2708/head
Jan Sandbrink 10 years ago
parent bc9fb20215
commit db475e025a
  1. 60
      lib/api/v3/work_packages/form/work_package_attribute_links_representer.rb

@ -53,59 +53,39 @@ module API
self.as_strategy = ::API::Utilities::CamelCasingStrategy.new self.as_strategy = ::API::Utilities::CamelCasingStrategy.new
def self.linked_property(property_name: nil, def self.linked_property(property,
namespace: nil, namespace: property.to_s.pluralize,
method: nil, association: "#{property}_id",
path: nil) path: property)
property property_name, property property,
exec_context: :decorator, exec_context: :decorator,
getter: -> (*) { getter: -> (*) {
get_path(get_method: method, get_path(get_method: association,
path: path) path: path)
}, },
setter: -> (value, *) { setter: -> (value, *) {
parse_link(property: property_name, parse_link(property: property,
namespace: namespace, namespace: namespace,
value: value, value: value,
setter_method: :"#{method}=") setter_method: :"#{association}=")
} }
end end
linked_property(property_name: :type, linked_property :type
namespace: :types, linked_property :status
method: :type_id, linked_property :assignee,
path: :type)
linked_property(property_name: :status,
namespace: :statuses,
method: :status_id,
path: :status)
linked_property(property_name: :assignee,
namespace: :users, namespace: :users,
method: :assigned_to_id, association: :assigned_to_id,
path: :user) path: :user
linked_property :responsible,
linked_property(property_name: :responsible,
namespace: :users, namespace: :users,
method: :responsible_id, association: :responsible_id,
path: :user) path: :user
linked_property :category
linked_property(property_name: :category, linked_property :version,
namespace: :categories, association: :fixed_version_id
method: :category_id, linked_property :priority
path: :category)
linked_property(property_name: :version,
namespace: :versions,
method: :fixed_version_id,
path: :version)
linked_property(property_name: :priority,
namespace: :priorities,
method: :priority_id,
path: :priority)
private private

Loading…
Cancel
Save