Sha256: 89c1434bb62eb242305da9b48d3d8273a763926c2a4a19c2def3bac332df717c
Contents?: true
Size: 1.1 KB
Versions: 5
Compression:
Stored size: 1.1 KB
Contents
module Scrivito # This class provides methods used to retrieve objects from CMS based an entry # in CMS of the obj_class <tt>NamedLink</tt>. # @api public class NamedLink # @api public class NotFound < StandardError end # This method will be called to retrieve the NamedLink {BasicObj Obj}. # By default it will look for the Obj at the path "_named_links". # Overwrite this method only if you know what you are doing. # @api public def self.find_named_link_obj BasicObj.find_by_path("/_named_links") end # Returns the CMS object mapped to the given title or nil. # The title can be a string of symbol. # @api public 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 def self.named_links named_link_obj = find_named_link_obj if named_link_obj named_link_obj.related_links else raise NotFound, "Couldn't find NamedLink CMS Object!" end end end end
Version data entries
5 entries across 5 versions & 1 rubygems