class WCC::Contentful::Model::Redirect
Public Instance Methods
external?()
click to toggle source
A menu link is external if `external_link` is present and not relative.
# File lib/wcc/contentful/model/redirect.rb, line 9 def external? external_uri&.scheme.present? end
external_uri()
click to toggle source
# File lib/wcc/contentful/model/redirect.rb, line 4 def external_uri @external_uri ||= URI(external_link) if external_link.present? end
fragment()
click to toggle source
# File lib/wcc/contentful/model/redirect.rb, line 26 def fragment WCC::Contentful::App::SectionHelper.section_id(section_link) if section_link end
href()
click to toggle source
Gets either the external link or the slug from the referenced page. Example usage: `redirect_to redirect.href`
# File lib/wcc/contentful/model/redirect.rb, line 15 def href return external_link if external_link url = (link&.try(:slug) || link&.try(:url)) return url unless fragment.present? url = URI(url || '') url.fragment = fragment url.to_s end