Module: HALPresenter::Links::ClassMethods

Defined in:
lib/hal_presenter/links.rb

Instance Method Summary collapse

Instance Method Details

#base_href=(base) ⇒ Object



9
10
11
# File 'lib/hal_presenter/links.rb', line 9

def base_href=(base)
  @base_href = base&.sub(%r(/*$), '')
end

#href(href) ⇒ Object



13
14
15
16
17
# File 'lib/hal_presenter/links.rb', line 13

def href(href)
  return href if (@base_href ||= '').empty?
  return href if href =~ %r(\A(\w+://)?[^/])
  @base_href + href
end