class RedirectService

  def initialize(token)
    @token = token
  end

  def url
    link.url
  end

  private
  attr_reader :token

  def link
    if @link
      return @link
    end
    Link.where(token: token).first || NoLink.new
  end
end

class RedirectService

  def initialize(token)
    @token = token
  end

  def url
    link.url
  end

  private
  attr_reader :token

  def link
    @link ||= Link.where(token: token).first || NoLink.new
  end
end

Fix redirect service link memoization
Fix redirect service link memoization

Summary
-------

While examining code coverage metrics, it seems that the memoization
inside the RedirectService object was not implemented correctly. The
"Link" value would never have been set, the condition to determine if
we've previously loaded the link would always fail, and we'd attempt
another lookup via ActiveRecord. This aims to fix all of that using
the mallot operator instead to assign the RedirectService's "Link".
