Class: Prismic::LinkResolver
- Inherits:
-
Object
- Object
- Prismic::LinkResolver
- Defined in:
- lib/prismic.rb
Overview
The LinkResolver will help to build URL specific to an application, based on a generic prismic.io's Document link.
The link_resolver function is the recommended way to create a LinkResolver.
Instance Attribute Summary collapse
-
#ref ⇒ Object
readonly
Returns the value of attribute ref.
Instance Method Summary collapse
-
#initialize(ref) {|doc_link| ... } ⇒ LinkResolver
constructor
A new instance of LinkResolver.
- #link_to(doc) ⇒ Object
Constructor Details
#initialize(ref) {|doc_link| ... } ⇒ LinkResolver
Returns a new instance of LinkResolver
544 545 546 547 |
# File 'lib/prismic.rb', line 544 def initialize(ref, &blk) @ref = ref @blk = blk end |
Instance Attribute Details
#ref ⇒ Object (readonly)
Returns the value of attribute ref
540 541 542 |
# File 'lib/prismic.rb', line 540 def ref @ref end |
Instance Method Details
#link_to(doc) ⇒ Object
548 549 550 551 552 553 554 555 |
# File 'lib/prismic.rb', line 548 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., doc.slug, doc.fragments, false) @blk.call(doc_link) end end |