class HALPresenter::Links::Link

Attributes

deprecation[R]
profile[R]
templated[RW]
title[R]
type[R]

Public Class Methods

new(rel, value = NO_VALUE, **kwargs, &block) click to toggle source
Calls superclass method HALPresenter::Property::new
# File lib/hal_presenter/links.rb, line 27
def initialize(rel, value = NO_VALUE, **kwargs, &block)
  @type =         kwargs[:type].freeze
  @deprecation =  kwargs[:deprecation].freeze
  @profile =      kwargs[:profile].freeze
  @title =        kwargs[:title].freeze

  curie = kwargs[:curie].to_s
  rel = [curie, rel.to_s].join(':') unless curie.empty?

  super(
    rel,
    value,
    embed_depth: kwargs[:embed_depth],
    context: kwargs[:context],
    &block
  )
end

Public Instance Methods

to_h(resource = nil, options = {}) click to toggle source
# File lib/hal_presenter/links.rb, line 45
def to_h(resource = nil, options = {})
  href = value(resource, options)
  return {} unless href

  {href: HALPresenter.href(href)}.tap do |hash|
    hash[:type]        = type        if type
    hash[:deprecation] = deprecation if deprecation
    hash[:profile]     = profile     if profile
    hash[:title]       = title       if title
    hash[:templated]   = templated   if templated
  end
end