Class: Scrivito::NamedLink

Inherits:
Object
  • Object
show all
Defined in:
lib/scrivito/named_link.rb

Overview

This class provides methods used to retrieve objects from CMS based an entry in CMS of the obj_class NamedLink.

Defined Under Namespace

Classes: NotFound

Class Method Summary collapse

Class Method Details

This method will be called to retrieve the NamedLink Obj. By default it will look for the Obj at the path “_named_links”. Override this method only if you know what you are doing.



16
17
18
# File 'lib/scrivito/named_link.rb', line 16

def self.find_named_link_obj
  BasicObj.find_by_path("/_named_links")
end

.get_object(title, options = {}) ⇒ Object

Returns the CMS object mapped to the given title or nil. The title can be a string of symbol.

Raises:



23
24
25
26
27
# File 'lib/scrivito/named_link.rb', line 23

def self.get_object(title, options = {})
  link = named_links.find { |link| link.title == title.to_s }
  raise NotFound, "The NamedLink '#{title.to_s}' does not exist" unless link
  link.obj
end