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
def self.linked_property(property_name: nil,
namespace: nil,
method: nil,
path: nil)
def self.linked_property(property,
namespace: property.to_s.pluralize,
association: "#{property}_id",
path: property)
property property_name,
property property,
exec_context: :decorator,
getter: -> (*) {
get_path(get_method: method,
get_path(get_method: association,
path: path)
},
setter: -> (value, *) {
parse_link(property: property_name,
parse_link(property: property,
namespace: namespace,
value: value,
setter_method: :"#{method}=")
setter_method: :"#{association}=")
}
end
linked_property(property_name: :type,
namespace: :types,
method: :type_id,
path: :type)
linked_property(property_name: :status,
namespace: :statuses,
method: :status_id,
path: :status)
linked_property(property_name: :assignee,
linked_property :type
linked_property :status
linked_property :assignee,
namespace: :users,
method: :assigned_to_id,
path: :user)
linked_property(property_name: :responsible,
association: :assigned_to_id,
path: :user
linked_property :responsible,
namespace: :users,
method: :responsible_id,
path: :user)
linked_property(property_name: :category,
namespace: :categories,
method: :category_id,
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)
association: :responsible_id,
path: :user
linked_property :category
linked_property :version,
association: :fixed_version_id
linked_property :priority
private

Loading…
Cancel
Save