class Prismic::LinkResolver
The LinkResolver
will help to build URL specific to an application, based on a generic prismic.io's {Fragments::DocumentLink Document
link}.
The {Prismic.link_resolver} function is the recommended way to create a LinkResolver
.
Attributes
ref[R]
Public Class Methods
new(ref, &blk)
click to toggle source
@yieldparam doc_link [Fragments::DocumentLink] A DocumentLink instance @yieldreturn [String] The application specific URL of the given document
# File lib/prismic.rb, line 566 def initialize(ref, &blk) @ref = ref @blk = blk end
Public Instance Methods
link_to(doc)
click to toggle source
# File lib/prismic.rb, line 570 def link_to(doc) if doc.is_a? Prismic::Fragments::DocumentLink @blk.call(doc) elsif doc.is_a? Prismic::Document doc_link = Prismic::Fragments::DocumentLink.new(doc.id, doc.uid, doc.type, doc.tags, doc.slug, doc.lang, doc.fragments, false) @blk.call(doc_link) end end