module HALPresenter::Links
Public Class Methods
included(base)
click to toggle source
# File lib/hal_presenter/links.rb, line 59 def self.included(base) base.extend ClassMethods end
Public Instance Methods
link(rel, value = nil, **kwargs, &block)
click to toggle source
# File lib/hal_presenter/links.rb, line 63 def link(rel, value = nil, **kwargs, &block) if value.nil? && !block_given? raise 'link must be called with non nil value or be given a block' end kwargs[:context] ||= self rel = rel.to_sym if rel == :self || kwargs[:replace_parent] links.delete_if { |link| link.rel == rel } end Link.new(rel, value, **kwargs, &block).tap do |link| links << link end end
Protected Instance Methods
links()
click to toggle source
# File lib/hal_presenter/links.rb, line 82 def links @__links ||= __init_from_superclass(:links) end