Skip to content

Add links conditionally #126

Closed
Closed
@zubin

Description

@zubin

My use case is to only include possible actions on a resource.

I want to omit ones which aren't relevant, depending on the resource state.

Something like this:

link :boom do
  if @object.can_go_boom?
    href "the-boom-url"
  end
end

Currently this results in links: {boom: nil} but I'd prefer any links which are nil to be removed (like Hash#compact).

Does this make sense? I'd be happy to make a PR if the idea is sound.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions