Class: RailsConnector::NamedLink

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_connector/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

.cache_expiry_time=(value) ⇒ Object

Sets the time in minutes after which the cache will be expired. The default expiry time is set to 1 minute


41
42
43
# File 'lib/rails_connector/named_link.rb', line 41

def self.cache_expiry_time=(value)
  @@cache_expiry_time = value
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. If :cache => false is provided, the object will not be fetched from the cache.

Raises:


57
58
59
60
61
# File 'lib/rails_connector/named_link.rb', line 57

def self.get_object(title, options = {})
  object = named_links[title.to_s]
  raise NotFound, "The NamedLink '#{title.to_s}' does not exist" if object.nil?
  options[:cache] == false ? object.reload : object
end