make self_link even more awesome

pull/2516/head
Jan Sandbrink 10 years ago
parent 4f7836dda5
commit 7c2a686657
  1. 3
      lib/api/decorators/single.rb
  2. 2
      lib/api/v3/priorities/priority_representer.rb
  3. 2
      lib/api/v3/projects/project_representer.rb
  4. 2
      lib/api/v3/statuses/status_representer.rb
  5. 2
      lib/api/v3/users/user_representer.rb
  6. 2
      lib/api/v3/versions/version_representer.rb
  7. 2
      lib/api/v3/work_packages/work_package_representer.rb

@ -51,8 +51,9 @@ module API
exec_context: :decorator,
render_nil: false
def self.self_link(path, title_getter: -> (*) { represented.name })
def self.self_link(path: nil, title_getter: -> (*) { represented.name })
link :self do
path = _type.underscore unless path
link_object = { href: api_v3_paths.send(path, represented.id) }
link_object[:title] = instance_eval(&title_getter)

@ -35,7 +35,7 @@ module API
module Priorities
class PriorityRepresenter < ::API::Decorators::Single
self_link :priority
self_link
property :id, render_nil: true
property :name

@ -35,7 +35,7 @@ module API
module Projects
class ProjectRepresenter < ::API::Decorators::Single
self_link :project
self_link
link 'categories' do
{ href: api_v3_paths.categories(represented.id) }

@ -32,7 +32,7 @@ module API
module Statuses
class StatusRepresenter < ::API::Decorators::Single
self_link :status
self_link
property :id, render_nil: true
property :name

@ -36,7 +36,7 @@ module API
class UserRepresenter < ::API::Decorators::Single
include AvatarHelper
self_link :user
self_link
link :lock do
{

@ -35,7 +35,7 @@ module API
module Versions
class VersionRepresenter < ::API::Decorators::Single
self_link :version
self_link
linked_property :definingProject,
path: :project,

@ -35,7 +35,7 @@ module API
module WorkPackages
class WorkPackageRepresenter < ::API::Decorators::Single
self_link :work_package, title_getter: -> (*) { represented.subject }
self_link title_getter: -> (*) { represented.subject }
link :update do
{

Loading…
Cancel
Save